1 ;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Package: odbc -*-
2 ;;;; *************************************************************************
3 ;;;; FILE IDENTIFICATION
5 ;;;; Name: odbc-ff-interface.lisp
6 ;;;; Purpose: Function definitions for UFFI interface to ODBC
7 ;;;; Author: Kevin M. Rosenberg
9 ;;;; $Id: odbc-package.lisp 7061 2003-09-07 06:34:45Z kevin $
11 ;;;; This file, part of CLSQL, is Copyright (c) 2004 by Kevin M. Rosenberg
12 ;;;; and Copyright (C) Paul Meurer 1999 - 2001. All rights reserved.
14 ;;;; CLSQL users are granted the rights to distribute and use this software
15 ;;;; as governed by the terms of the Lisp Lesser GNU Public License
16 ;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL.
17 ;;;; *************************************************************************
21 (def-foreign-type sql-handle :pointer-void)
22 (def-foreign-type sql-handle-ptr '(* sql-handle))
23 (def-foreign-type string-ptr '(* :unsigned-char))
24 (def-type long-ptr-type '(* :long))
27 (def-function "SQLAllocEnv"
28 ((*phenv sql-handle-ptr) ; HENV FAR *phenv
31 :returning :short) ; RETCODE_SQL_API
33 (def-function "SQLAllocConnect"
34 ((henv sql-handle) ; HENV henv
35 (*phdbc sql-handle-ptr) ; HDBC FAR *phdbc
38 :returning :short) ; RETCODE_SQL_API
40 (def-function "SQLConnect"
41 ((hdbc sql-handle) ; HDBC hdbc
42 (*szDSN :cstring) ; UCHAR FAR *szDSN
43 (cbDSN :short) ; SWORD cbDSN
44 (*szUID :cstring) ; UCHAR FAR *szUID
45 (cbUID :short) ; SWORD cbUID
46 (*szAuthStr :cstring) ; UCHAR FAR *szAuthStr
47 (cbAuthStr :short) ; SWORD cbAuthStr
50 :returning :short) ; RETCODE_SQL_API
52 (def-function "SQLDriverConnect"
53 ((hdbc sql-handle) ; HDBC hdbc
54 (hwnd sql-handle) ; SQLHWND hwnd
55 (*szConnStrIn string-ptr) ; UCHAR FAR *szConnStrIn
56 (cbConnStrIn :short) ; SWORD cbConnStrIn
57 (*szConnStrOut string-ptr) ; UCHAR FAR *szConnStrOut
58 (cbConnStrOutMax :short) ; SWORD cbConnStrOutMax
59 (*pcbConnStrOut :pointer-void) ; SWORD FAR *pcbConnStrOut
60 (fDriverCompletion :short) ; UWORD fDriverCompletion
63 :returning :short) ; RETCODE_SQL_API
65 (def-function "SQLDisconnect"
66 ((hdbc sql-handle)) ; HDBC hdbc
68 :returning :short) ; RETCODE_SQL_API
70 (def-function "SQLAllocStmt"
71 ((hdbc sql-handle) ; HDBC hdbc
72 (*phstmt sql-handle-ptr) ; HSTMT FAR *phstmt
75 :returning :short) ; RETCODE_SQL_API
77 (def-function "SQLGetInfo"
78 ((hdbc sql-handle) ; HDBC hdbc
79 (fInfoType :short) ; UWORD fInfoType
80 (rgbInfoValue :pointer-void) ; PTR rgbInfoValue
81 (cbInfoValueMax :short) ; SWORD cbInfoValueMax
82 (*pcbInfoValue :pointer-void) ; SWORD FAR *pcbInfoValue
85 :returning :short) ; RETCODE_SQL_API
87 (def-function "SQLPrepare"
88 ((hstmt sql-handle) ; HSTMT hstmt
89 (*szSqlStr :cstring) ; UCHAR FAR *szSqlStr
90 (cbSqlStr :long) ; SDWORD cbSqlStr
93 :returning :short) ; RETCODE_SQL_API
95 (def-function "SQLExecute"
96 ((hstmt sql-handle) ; HSTMT hstmt
99 :returning :short) ; RETCODE_SQL_API
101 (def-function "SQLExecDirect"
102 ((hstmt sql-handle) ; HSTMT hstmt
103 (*szSqlStr :cstring) ; UCHAR FAR *szSqlStr
104 (cbSqlStr :long) ; SDWORD cbSqlStr
107 :returning :short) ; RETCODE_SQL_API
109 (def-function "SQLFreeStmt"
110 ((hstmt sql-handle) ; HSTMT hstmt
111 (fOption :short)) ; UWORD fOption
113 :returning :short) ; RETCODE_SQL_API
115 (def-function "SQLCancel"
116 ((hstmt sql-handle) ; HSTMT hstmt
119 :returning :short) ; RETCODE_SQL_API
121 (def-function "SQLError"
122 ((henv sql-handle) ; HENV henv
123 (hdbc sql-handle) ; HDBC hdbc
124 (hstmt sql-handle) ; HSTMT hstmt
125 (*szSqlState string-ptr) ; UCHAR FAR *szSqlState
126 (*pfNativeError (* :long)) ; SDWORD FAR *pfNativeError
127 (*szErrorMsg string-ptr) ; UCHAR FAR *szErrorMsg
128 (cbErrorMsgMax :short) ; SWORD cbErrorMsgMax
129 (*pcbErrorMsg (* :short)) ; SWORD FAR *pcbErrorMsg
132 :returning :short) ; RETCODE_SQL_API
134 (def-function "SQLNumResultCols"
135 ((hstmt sql-handle) ; HSTMT hstmt
136 (*pccol (* :short)) ; SWORD FAR *pccol
139 :returning :short) ; RETCODE_SQL_API
141 (def-function "SQLRowCount"
142 ((hstmt sql-handle) ; HSTMT hstmt
143 (*pcrow (* :long)) ; SDWORD FAR *pcrow
146 :returning :short) ; RETCODE_SQL_API
148 (def-function "SQLDescribeCol"
149 ((hstmt sql-handle) ; HSTMT hstmt
150 (icol :short) ; UWORD icol
151 (*szColName string-ptr) ; UCHAR FAR *szColName
152 (cbColNameMax :short) ; SWORD cbColNameMax
153 (*pcbColName (* :short)) ; SWORD FAR *pcbColName
154 (*pfSqlType (* :short)) ; SWORD FAR *pfSqlType
155 (*pcbColDef (* :unsigned-long)) ; UDWORD FAR *pcbColDef
156 (*pibScale (* :short)) ; SWORD FAR *pibScale
157 (*pfNullable (* :short)) ; SWORD FAR *pfNullable
160 :returning :short) ; RETCODE_SQL_API
162 (def-function "SQLColAttributes"
163 ((hstmt sql-handle) ; HSTMT hstmt
164 (icol :short) ; UWORD icol
165 (fDescType :short) ; UWORD fDescType
166 (rgbDesc string-ptr) ; PTR rgbDesc
167 (cbDescMax :short) ; SWORD cbDescMax
168 (*pcbDesc (* :short)) ; SWORD FAR *pcbDesc
169 (*pfDesc (* :long)) ; SDWORD FAR *pfDesc
172 :returning :short) ; RETCODE_SQL_API
174 (def-function "SQLColumns"
175 ((hstmt sql-handle) ; HSTMT hstmt
176 (*szTableQualifier :cstring) ; UCHAR FAR *szTableQualifier
177 (cbTableQualifier :short) ; SWORD cbTableQualifier
178 (*szTableOwner :cstring) ; UCHAR FAR *szTableOwner
179 (cbTableOwner :short) ; SWORD cbTableOwner
180 (*szTableName :cstring) ; UCHAR FAR *szTableName
181 (cbTableName :short) ; SWORD cbTableName
182 (*szColumnName :cstring) ; UCHAR FAR *szColumnName
183 (cbColumnName :short) ; SWORD cbColumnName
186 :returning :short) ; RETCODE_SQL_API
188 (def-function "SQLBindCol"
189 ((hstmt sql-handle) ; HSTMT hstmt
190 (icol :short) ; UWORD icol
191 (fCType :short) ; SWORD fCType
192 (rgbValue :pointer-void) ; PTR rgbValue
193 (cbValueMax :long) ; SDWORD cbValueMax
194 (*pcbValue (* :long)) ; SDWORD FAR *pcbValue
197 :returning :short) ; RETCODE_SQL_API
199 (def-function "SQLFetch"
200 ((hstmt sql-handle) ; HSTMT hstmt
203 :returning :short) ; RETCODE_SQL_API
205 (def-function "SQLTransact"
206 ((henv sql-handle) ; HENV henv
207 (hdbc sql-handle) ; HDBC hdbc
208 (fType :short) ; UWORD fType ($SQL_COMMIT or $SQL_ROLLBACK)
211 :returning :short) ; RETCODE_SQL_API
214 (def-function "SQLDescribeParam"
215 ((hstmt sql-handle) ; HSTMT hstmt
216 (ipar :short) ; UWORD ipar
217 (*pfSqlType (* :short)) ; SWORD FAR *pfSqlType
218 (*pcbColDef (* :unsigned-long)) ; UDWORD FAR *pcbColDef
219 (*pibScale (* :short)) ; SWORD FAR *pibScale
220 (*pfNullable (* :short)) ; SWORD FAR *pfNullable
223 :returning :short) ; RETCODE_SQL_API
226 (def-function "SQLBindParameter"
227 ((hstmt sql-handle) ; HSTMT hstmt
228 (ipar :short) ; UWORD ipar
229 (fParamType :short) ; SWORD fParamType
230 (fCType :short) ; SWORD fCType
231 (fSqlType :short) ; SWORD fSqlType
232 (cbColDef :long) ; UDWORD cbColDef
233 (ibScale :short) ; SWORD ibScale
234 (rgbValue :pointer-void) ; PTR rgbValue
235 (cbValueMax :long) ; SDWORD cbValueMax
236 (*pcbValue :pointer-void) ; SDWORD FAR *pcbValue
239 :returning :short) ; RETCODE_SQL_API
242 (def-function "SQLGetData"
243 ((hstmt sql-handle) ; HSTMT hstmt
244 (icol :short) ; UWORD icol
245 (fCType :short) ; SWORD fCType
246 (rgbValue :pointer-void) ; PTR rgbValue
247 (cbValueMax :long) ; SDWORD cbValueMax
248 (*pcbValue :pointer-void) ; SDWORD FAR *pcbValue
251 :returning :short) ; RETCODE_SQL_API
253 (def-function "SQLParamData"
254 ((hstmt sql-handle) ; HSTMT hstmt
255 (*prgbValue :pointer-void) ; PTR FAR *prgbValue
258 :returning :short) ; RETCODE_SQL_API
260 (def-function "SQLPutData"
261 ((hstmt sql-handle) ; HSTMT hstmt
262 (rgbValue :pointer-void) ; PTR rgbValue
263 (cbValue :long) ; SDWORD cbValue
266 :returning :short) ; RETCODE_SQL_API
268 (def-function "SQLGetConnectOption"
269 ((hdbc sql-handle) ; HDBC hdbc
270 (fOption :short) ; UWORD fOption
271 (pvParam :pointer-void) ; PTR pvParam
274 :returning :short) ; RETCODE_SQL_API
276 (def-function "SQLSetConnectOption"
277 ((hdbc sql-handle) ; HDBC hdbc
278 (fOption :short) ; UWORD fOption
279 (vParam :long) ; UDWORD vParam
282 :returning :short) ; RETCODE_SQL_API
284 (def-function "SQLSetPos"
285 ((hstmt sql-handle) ; HSTMT hstmt
286 (irow :short) ; UWORD irow
287 (fOption :short) ; UWORD fOption
288 (fLock :short) ; UWORD fLock
291 :returning :short) ; RETCODE_SQL_API
294 (def-function "SQLExtendedFetch"
295 ((hstmt sql-handle) ; HSTMT hstmt
296 (fFetchType :short) ; UWORD fFetchType
297 (irow :long) ; SDWORD irow
298 (*pcrow :pointer-void) ; UDWORD FAR *pcrow
299 (*rgfRowStatus :pointer-void) ; UWORD FAR *rgfRowStatus
302 :returning :short) ; RETCODE_SQL_API
304 (def-function "SQLDataSources"
305 ((henv sql-handle) ; HENV henv
307 (*szDSN string-ptr) ; UCHAR FAR *szDSN
308 (cbDSNMax :short) ; SWORD cbDSNMax
309 (*pcbDSN :pointer-void) ; SWORD *pcbDSN
310 (*szDescription string-ptr) ; UCHAR *szDescription
311 (cbDescriptionMax :short) ; SWORD cbDescriptionMax
312 (*pcbDescription :pointer-void) ; SWORD *pcbDescription
315 :returning :short) ; RETCODE_SQL_API
317 (def-function "SQLFreeEnv"
318 ((henv sql-handle) ; HSTMT hstmt
321 :returning :short) ; RETCODE_SQL_API
324 ;;; foreign type definitions
326 ;;(defmacro %sql-len-data-at-exec (length)
327 ;; `(- $SQL_LEN_DATA_AT_EXEC_OFFSET ,length))
330 (def-struct sql-c-time
335 (def-struct sql-c-date
340 (def-struct sql-c-timestamp
351 (def-function "SQLSetEnvAttr"
352 ((henv sql-handle) ; HENV henv
354 (*value :pointer-void)
359 (def-function "SQLTables"
360 ((hstmt :pointer-void)
361 (catalog-name :pointer-void)
362 (catalog-name-length :short)
363 (schema-name :pointer-void)
364 (schema-name-length :short)
365 (table-name :pointer-void)
366 (table-name-length :short)
367 (table-type-name :pointer-void)
368 (table-type-name-length :short))