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 (* :void))
22 (def-foreign-type sql-handle-ptr (* sql-handle))
23 (def-foreign-type string-ptr (* :void))
25 (def-type long-ptr-type '(* :long))
28 (def-function "SQLAllocEnv"
29 ((*phenv sql-handle-ptr) ; HENV FAR *phenv
32 :returning :short) ; RETCODE_SQL_API
34 (def-function "SQLAllocConnect"
35 ((henv sql-handle) ; HENV henv
36 (*phdbc sql-handle-ptr) ; HDBC FAR *phdbc
39 :returning :short) ; RETCODE_SQL_API
41 (def-function "SQLConnect"
42 ((hdbc sql-handle) ; HDBC hdbc
43 (*szDSN string-ptr) ; UCHAR FAR *szDSN
44 (cbDSN :short) ; SWORD cbDSN
45 (*szUID string-ptr) ; UCHAR FAR *szUID
46 (cbUID :short) ; SWORD cbUID
47 (*szAuthStr string-ptr) ; UCHAR FAR *szAuthStr
48 (cbAuthStr :short) ; SWORD cbAuthStr
51 :returning :short) ; RETCODE_SQL_API
53 (def-function "SQLDriverConnect"
54 ((hdbc sql-handle) ; HDBC hdbc
55 (hwnd sql-handle) ; SQLHWND hwnd
56 (*szConnStrIn string-ptr) ; UCHAR FAR *szConnStrIn
57 (cbConnStrIn :short) ; SWORD cbConnStrIn
58 (*szConnStrOut string-ptr) ; UCHAR FAR *szConnStrOut
59 (cbConnStrOutMax :short) ; SWORD cbConnStrOutMax
60 (*pcbConnStrOut :pointer-void) ; SWORD FAR *pcbConnStrOut
61 (fDriverCompletion :short) ; UWORD fDriverCompletion
64 :returning :short) ; RETCODE_SQL_API
66 (def-function "SQLDisconnect"
67 ((hdbc sql-handle)) ; HDBC hdbc
69 :returning :short) ; RETCODE_SQL_API
71 (def-function "SQLAllocStmt"
72 ((hdbc sql-handle) ; HDBC hdbc
73 (*phstmt sql-handle-ptr) ; HSTMT FAR *phstmt
76 :returning :short) ; RETCODE_SQL_API
78 (def-function "SQLGetInfo"
79 ((hdbc sql-handle) ; HDBC hdbc
80 (fInfoType :short) ; UWORD fInfoType
81 (rgbInfoValue :pointer-void) ; PTR rgbInfoValue
82 (cbInfoValueMax :short) ; SWORD cbInfoValueMax
83 (*pcbInfoValue :pointer-void) ; SWORD FAR *pcbInfoValue
86 :returning :short) ; RETCODE_SQL_API
88 (def-function "SQLPrepare"
89 ((hstmt sql-handle) ; HSTMT hstmt
90 (*szSqlStr string-ptr) ; UCHAR FAR *szSqlStr
91 (cbSqlStr :long) ; SDWORD cbSqlStr
94 :returning :short) ; RETCODE_SQL_API
96 (def-function "SQLExecute"
97 ((hstmt sql-handle) ; HSTMT hstmt
100 :returning :short) ; RETCODE_SQL_API
102 (def-function "SQLExecDirect"
103 ((hstmt sql-handle) ; HSTMT hstmt
104 (*szSqlStr string-ptr) ; UCHAR FAR *szSqlStr
105 (cbSqlStr :long) ; SDWORD cbSqlStr
108 :returning :short) ; RETCODE_SQL_API
110 (def-function "SQLFreeStmt"
111 ((hstmt sql-handle) ; HSTMT hstmt
112 (fOption :short)) ; UWORD fOption
114 :returning :short) ; RETCODE_SQL_API
116 (def-function "SQLCancel"
117 ((hstmt sql-handle) ; HSTMT hstmt
120 :returning :short) ; RETCODE_SQL_API
122 (def-function "SQLError"
123 ((henv sql-handle) ; HENV henv
124 (hdbc sql-handle) ; HDBC hdbc
125 (hstmt sql-handle) ; HSTMT hstmt
126 (*szSqlState string-ptr) ; UCHAR FAR *szSqlState
127 (*pfNativeError :pointer-void) ; SDWORD FAR *pfNativeError
128 (*szErrorMsg string-ptr) ; UCHAR FAR *szErrorMsg
129 (cbErrorMsgMax :short) ; SWORD cbErrorMsgMax
130 (*pcbErrorMsg :pointer-void) ; SWORD FAR *pcbErrorMsg
133 :returning :short) ; RETCODE_SQL_API
135 (def-function "SQLNumResultCols"
136 ((hstmt sql-handle) ; HSTMT hstmt
137 (*pccol :pointer-void) ; SWORD FAR *pccol
140 :returning :short) ; RETCODE_SQL_API
142 (def-function "SQLRowCount"
143 ((hstmt sql-handle) ; HSTMT hstmt
144 (*pcrow :pointer-void) ; SDWORD FAR *pcrow
147 :returning :short) ; RETCODE_SQL_API
149 (def-function "SQLDescribeCol"
150 ((hstmt sql-handle) ; HSTMT hstmt
151 (icol :short) ; UWORD icol
152 (*szColName string-ptr) ; UCHAR FAR *szColName
153 (cbColNameMax :short) ; SWORD cbColNameMax
154 (*pcbColName :pointer-void) ; SWORD FAR *pcbColName
155 (*pfSqlType :pointer-void) ; SWORD FAR *pfSqlType
156 (*pcbColDef :pointer-void) ; UDWORD FAR *pcbColDef
157 (*pibScale :pointer-void) ; SWORD FAR *pibScale
158 (*pfNullable :pointer-void) ; SWORD FAR *pfNullable
161 :returning :short) ; RETCODE_SQL_API
163 (def-function "SQLColAttributes"
164 ((hstmt sql-handle) ; HSTMT hstmt
165 (icol :short) ; UWORD icol
166 (fDescType :short) ; UWORD fDescType
167 (rgbDesc :pointer-void) ; PTR rgbDesc
168 (cbDescMax :short) ; SWORD cbDescMax
169 (*pcbDesc :pointer-void) ; SWORD FAR *pcbDesc
170 (*pfDesc :pointer-void) ; SDWORD FAR *pfDesc
173 :returning :short) ; RETCODE_SQL_API
175 (def-function "SQLColumns"
176 ((hstmt sql-handle) ; HSTMT hstmt
177 (*szTableQualifier string-ptr) ; UCHAR FAR *szTableQualifier
178 (cbTableQualifier :short) ; SWORD cbTableQualifier
179 (*szTableOwner string-ptr) ; UCHAR FAR *szTableOwner
180 (cbTableOwner :short) ; SWORD cbTableOwner
181 (*szTableName string-ptr) ; UCHAR FAR *szTableName
182 (cbTableName :short) ; SWORD cbTableName
183 (*szColumnName string-ptr) ; UCHAR FAR *szColumnName
184 (cbColumnName :short) ; SWORD cbColumnName
187 :returning :short) ; RETCODE_SQL_API
189 (def-function "SQLBindCol"
190 ((hstmt sql-handle) ; HSTMT hstmt
191 (icol :short) ; UWORD icol
192 (fCType :short) ; SWORD fCType
193 (rgbValue :pointer-void) ; PTR rgbValue
194 (cbValueMax :long) ; SDWORD cbValueMax
195 (*pcbValue :pointer-void) ; SDWORD FAR *pcbValue
198 :returning :short) ; RETCODE_SQL_API
200 (def-function "SQLFetch"
201 ((hstmt sql-handle) ; HSTMT hstmt
204 :returning :short) ; RETCODE_SQL_API
206 (def-function "SQLTransact"
207 ((henv sql-handle) ; HENV henv
208 (hdbc sql-handle) ; HDBC hdbc
209 (fType :short) ; UWORD fType ($SQL_COMMIT or $SQL_ROLLBACK)
212 :returning :short) ; RETCODE_SQL_API
215 (def-function "SQLDescribeParam"
216 ((hstmt sql-handle) ; HSTMT hstmt
217 (ipar :short) ; UWORD ipar
218 (*pfSqlType :pointer-void) ; SWORD FAR *pfSqlType
219 (*pcbColDef :pointer-void) ; UDWORD FAR *pcbColDef
220 (*pibScale :pointer-void) ; SWORD FAR *pibScale
221 (*pfNullable :pointer-void) ; SWORD FAR *pfNullable
224 :returning :short) ; RETCODE_SQL_API
227 (def-function "SQLBindParameter"
228 ((hstmt sql-handle) ; HSTMT hstmt
229 (ipar :short) ; UWORD ipar
230 (fParamType :short) ; SWORD fParamType
231 (fCType :short) ; SWORD fCType
232 (fSqlType :short) ; SWORD fSqlType
233 (cbColDef :long) ; UDWORD cbColDef
234 (ibScale :short) ; SWORD ibScale
235 (rgbValue :pointer-void) ; PTR rgbValue
236 (cbValueMax :long) ; SDWORD cbValueMax
237 (*pcbValue :pointer-void) ; SDWORD FAR *pcbValue
240 :returning :short) ; RETCODE_SQL_API
243 (def-function "SQLGetData"
244 ((hstmt sql-handle) ; HSTMT hstmt
245 (icol :short) ; UWORD icol
246 (fCType :short) ; SWORD fCType
247 (rgbValue :pointer-void) ; PTR rgbValue
248 (cbValueMax :long) ; SDWORD cbValueMax
249 (*pcbValue :pointer-void) ; SDWORD FAR *pcbValue
252 :returning :short) ; RETCODE_SQL_API
254 (def-function "SQLParamData"
255 ((hstmt sql-handle) ; HSTMT hstmt
256 (*prgbValue :pointer-void) ; PTR FAR *prgbValue
259 :returning :short) ; RETCODE_SQL_API
261 (def-function "SQLPutData"
262 ((hstmt sql-handle) ; HSTMT hstmt
263 (rgbValue :pointer-void) ; PTR rgbValue
264 (cbValue :long) ; SDWORD cbValue
267 :returning :short) ; RETCODE_SQL_API
269 (def-function "SQLGetConnectOption"
270 ((hdbc sql-handle) ; HDBC hdbc
271 (fOption :short) ; UWORD fOption
272 (pvParam :pointer-void) ; PTR pvParam
275 :returning :short) ; RETCODE_SQL_API
277 (def-function "SQLSetConnectOption"
278 ((hdbc sql-handle) ; HDBC hdbc
279 (fOption :short) ; UWORD fOption
280 (vParam :long) ; UDWORD vParam
283 :returning :short) ; RETCODE_SQL_API
285 (def-function "SQLSetPos"
286 ((hstmt sql-handle) ; HSTMT hstmt
287 (irow :short) ; UWORD irow
288 (fOption :short) ; UWORD fOption
289 (fLock :short) ; UWORD fLock
292 :returning :short) ; RETCODE_SQL_API
295 (def-function "SQLExtendedFetch"
296 ((hstmt sql-handle) ; HSTMT hstmt
297 (fFetchType :short) ; UWORD fFetchType
298 (irow :long) ; SDWORD irow
299 (*pcrow :pointer-void) ; UDWORD FAR *pcrow
300 (*rgfRowStatus :pointer-void) ; UWORD FAR *rgfRowStatus
303 :returning :short) ; RETCODE_SQL_API
305 (def-function "SQLDataSources"
306 ((henv sql-handle) ; HENV henv
308 (*szDSN string-ptr) ; UCHAR FAR *szDSN
309 (cbDSNMax :short) ; SWORD cbDSNMax
310 (*pcbDSN :pointer-void) ; SWORD *pcbDSN
311 (*szDescription string-ptr) ; UCHAR *szDescription
312 (cbDescriptionMax :short) ; SWORD cbDescriptionMax
313 (*pcbDescription :pointer-void) ; SWORD *pcbDescription
316 :returning :short) ; RETCODE_SQL_API
318 (def-function "SQLFreeEnv"
319 ((henv sql-handle) ; HSTMT hstmt
322 :returning :short) ; RETCODE_SQL_API
325 ;;; foreign type definitions
327 ;;(defmacro %sql-len-data-at-exec (length)
328 ;; `(- $SQL_LEN_DATA_AT_EXEC_OFFSET ,length))
331 (def-struct sql-c-time
336 (def-struct sql-c-date
341 (def-struct sql-c-timestamp