 
 C: <column> column
 
-: odbc-describe-column ( statement n -- column )
-  dup >r
-  1024 CHAR: space <string> ascii string>alien dup >r
-  1024
-  0 short <ref>
-  0 short <ref> dup >r
-  0 uint <ref> dup >r
-  0 short <ref> dup >r
-  0 short <ref> dup >r
+:: odbc-describe-column ( statement columnNumber -- column )
+  1024 :> bufferLen
+  bufferLen CHAR: space <string> ascii string>alien :> columnName
+  0 short <ref> :> nameLengthPtr
+  0 short <ref> :> dataTypePtr
+  0 uint <ref> :> columnSizePtr
+  0 short <ref> :> decimalDigitsPtr
+  0 short <ref> :> nullablePtr
+  statement columnNumber columnName bufferLen nameLengthPtr
+  dataTypePtr columnSizePtr decimalDigitsPtr nullablePtr
   SQLDescribeCol succeeded? [
-    r> short deref
-    r> short deref
-    r> uint deref
-    r> short deref convert-sql-type
-    r> ascii alien>string
-    r> <column>
-  ] [
-    r> drop r> drop r> drop r> drop r> drop r> drop
+    nullablePtr short deref
+    decimalDigitsPtr short deref
+    columnSizePtr uint deref
+    dataTypePtr short deref convert-sql-type
+    columnName ascii alien>string
+    columnNumber <column>
+  ] [
     "odbc-describe-column failed" throw
   ] if ;
 

  SQLDisconnect succeeded? [ "odbc-disconnect failed" throw ] unless ;

: odbc-prepare ( dbc string -- statement )
  >r alloc-stmt-handle dup r> dup length SQLPrepare succeeded? [ "odbc-prepare failed" throw ] unless ;

: odbc-free-statement ( statement -- )
  SQL-HANDLE-STMT swap SQLFreeHandle succeeded? [ "odbc-free-statement failed" throw ] unless ;


C: <field> field

:: odbc-get-field ( statement column! -- field )
  column column? [ statement column odbc-describe-column column! ] unless
  8192 :> bufferLen
  bufferLen CHAR: space <string> ascii string>alien :> targetValuePtr

  statement column number>> SQL-C-DEFAULT
  targetValuePtr bufferLen f SQLGetData succeeded? [
      targetValuePtr column [ dereference-type-pointer ] keep <field>
  ] [
    column [
      "SQLGetData Failed for Column: " %
      dup name>> %
      " of type: " % dup type>> name>> %
