Notes about the low level ODBC interface Current file structure of library: odbc-library.dylan: the library and module definitions macros.dylan: wrapper for define-c-function to handle error return values sql.dylan: sql.h file from microsoft converted to c-ffi. Defines ODBC core level functions. sqlext.dylan: sqlext.h file from microsoft converted to c-ffi. Defines ODBC level 1 and level 2 functions. globals.dylan: This file should go away or be enhanced. It has some global variables for the connection and statement handles. error-handling: Error classes and error reporting functions. needs work. Eventual module setup: dylan-odbc: Defines functions which convert input variables as necessary to foreign pointers, and which return as multiple values all returns from the functions. dylan-odbc-ffi: Defines the very lowest level of functionality. To access these functions, you must supply appropriate foreign pointers to foreign types for those parameters which return output values in such pointers. dylan-odbc-internal: defines "-internal" versions of all the functions. These are all exported to be used by the above two modules, but it is not expected that users will ever make use of this directly. The dylan-odbc module has not yet been defined. A fair amount of boilerplate needs to be written to handle it, that is, to convert between dylan types and the low level C-FFI types that the dylan-odbc-ffi module functions take. The following types are referenced: :: a C datatype which refers to the allocated SQL Environment handle. :: a C datatype which refers to the ODBC Connection handle. :: a C datatype which refers to a statement handle. The following convention is used: input means that this is an ordinary parameter. output means that this is a parameter which points to storage for the specified ODBC function to fill in. Always implies pointer-to() with integer or short, and with string implies the storage for the string has been allocated. In the "dylan-odbc" library, output parameters would be returned as multiple values. input/output is only used in SQLBindParameter---sometimes this is for input and sometimes it is for output, so it is treated as an input and also returned as a multiple value. Or hm, I'm not sure how to handle this. Dylan-ODBC defines the following ODBC Core Functions: SQLAllocConnect (input environment :: , output connection :: ) SQLAllocEnv (output environment :: ) SQLAllocStmt (input connection :: , output statement :: ) SQLBindCol (input statement :: , input column-number :: , input C-data-type :: , output data :: , input data-length :: , output data-bytes-available :: ) SQLCancel (input statement :: ) SQLColAttributes (input statement :: , input column-number :: ) SQLConnect(input connection :: , input source-name :: , input source-length :: , input user :: , input user-length :: , input password :: , input password-length :: ) SQLDescribeCol(input statement :: , input column-number :: , output column-name :: , input max-col-name :: , output col-name-size :: , output column-type :: , output precision :: , output scale :: , output null-permitted :: ) SQLDisconnect(input connection :: ) SQLError(input environment :: , input connection :: , input statement :: , output sqlstate :: , output code :: , output message :: , input max-msg-size :: , output message-size :: ) SQLExecDirect(input statement :: , input string :: , input string-size :: ) SQLExecute(input statement :: ) SQLFetch(input statement :: ) SQLFreeConnect(input connection :: ) SQLFreeEnv(input environment :: ) SQLFreeStmt(input statement :: ) SQLGetCursorName(input statement :: , output cursor-name :: , input max-name-size :: , output actual-name-size :: ) SQLNumResultCols(input statement :: , output num-cols :: ) SQLPrepare(input statement :: , input string :: , input string-length :: ) SQLRowCount(input statement :: , output rowcount :: ) SQLSetCursorName(input statement :: , input cursor-name :: , input name-size :: ) SQLTransact(input environment :: , input connection :: , input flag :: ) SQLSetParam SQLSetParam is obsolete. Use SQLBindParameter instead. Dylan-ODBC defines the following ODBC Level 1 Functions: SQLColumns(input statement :: , input table-qualifier :: , input qualifier-length :: , input table-owner :: , input owner-length :: , input table-name :: , input name-length :: , input column-name :: , input column-length :: ) SQLDriverConnect(input connection :: , input window :: , input connection-string :: , input string-size :: , output real-conn-string :: , input max-r-c-size :: , output real-c-size :: , input completion-flag :: ) SQLGetConnectOption(input connection :: , input option :: , output value :: union(,)) SQLGetData(input statement :: , input column :: , input datatype :: , output value :: , input max-data-size :: , output actual-data-size :: ) SQLGetFunctions(input connection :: , input function :: , output status :: ) SQLGetInfo(input connection :: , input infotype :: , output value :: union(, ), input val-size :: , output value-size :: ) SQLGetTypeInfo(input statement :: , input datatype :: ) SQLParamData(input statement :: , output data :: ) SQLPutData(input statement :: , input data :: , input data-size :: ) SQLSetConnectOption(input connection :: , input option :: , input value :: ) SQLSpecialColumns(input statement :: , input col-type :: , input table-qualifier :: , input qualifier-size :: , input table-owner :: , input owner-size :: , input table-name :: , input name-size :: , scope :: , input nullable :: ) SQLStatistics(input statement :: , input table-qualifier :: , input qualifier-size :: , input table-owner :: , input owner-size :: , input table-name :: , input name-size :: , input unique :: , input accuracy :: ) SQLTables(input statement :: , input table-qualifier :: , input qualifier-size :: , input table-owner :: , input owner-size :: , input table-name :: , input name-size :: , input table-type :: , input type-size :: ) Dylan-ODBC defines the following ODBC Level 2 Functions: SQLDataSources(input environment :: , input direction :: , output data-source-name :: , input name-max-size :: , output name-real-size :: , output description :: , input desc-max-size :: , output desc-real-size :: ) SQLExtendedFetch(input statement :: , input type :: , input row-number :: , output rows-fetched :: , output status :: ) SQLMoreResults(input statement :: ) SQLNativeSql(input connection :: , input sql-string :: , input string-size :: , output translated-string :: , input max-trans-size :: , output real-trans-size :: ) SQLParamOptions(input statement :: , input numvalues :: , output rownumber :: ) SQLDrivers(input environment :: , input direction :: , output driver-desc :: , input driver-max-size :: , output driver-real-size :: , output attributes :: , input attr-max-size :: , output attr-real-size :: ) SQLBindParameter(input statement :: , input param-number :: , input param-type :: , input C-type :: , input precision :: , input scale :: , input/output param-buf :: , input buf-len :: , input/output real-buf-len :: ) The following are not documented in the book I have. I don't know which parameters are input and which are output. Level 1 functions: SQLGetStmtOption SQLSetStmtOption Level 2 functions: SQLBrowseConnect SQLColumnPrivileges SQLDescribeParam SQLForeignKeys SQLNumParams SQLPrimaryKeys SQLProcedureColumns SQLProcedures SQLSetPos SQLTablePrivileges SQLSetScrollOptions