 
 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 ;
 

  ] keep ;

: odbc-connect ( env dsn -- dbc )
   >r alloc-dbc-handle dup r>
   f swap dup length 1024 temp-string 0 short <ref> SQL-DRIVER-NOPROMPT
   SQLDriverConnect succeeded? [ "odbc-connect failed" throw ] unless ;


! See http://factorcode.org/license.txt for BSD license.
USING: accessors kernel alien alien.strings alien.syntax
combinators alien.c-types strings sequences namespaces make
words math threads io.encodings.ascii locals ;
IN: odbc

<< "odbc" "odbc32.dll" stdcall add-library >>
