odbcsql.nim 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845
  1. #
  2. #
  3. # Nim's Runtime Library
  4. # (c) Copyright 2015 Andreas Rumpf
  5. #
  6. # See the file "copying.txt", included in this
  7. # distribution, for details about the copyright.
  8. #
  9. when defined(nimPreviewSlimSystem):
  10. import std/widestrs
  11. when not defined(ODBCVER):
  12. const
  13. ODBCVER = 0x0351 ## define ODBC version 3.51 by default
  14. when defined(windows):
  15. {.push callconv: stdcall.}
  16. const odbclib = "odbc32.dll"
  17. else:
  18. {.push callconv: cdecl.}
  19. const odbclib = "libodbc.so"
  20. when defined(nimHasStyleChecks):
  21. {.push styleChecks: off.}
  22. # DATA TYPES CORRESPONDENCE
  23. # BDE fields ODBC types
  24. # ---------- ------------------
  25. # ftBlob SQL_BINARY
  26. # ftBoolean SQL_BIT
  27. # ftDate SQL_TYPE_DATE
  28. # ftTime SQL_TYPE_TIME
  29. # ftDateTime SQL_TYPE_TIMESTAMP
  30. # ftInteger SQL_INTEGER
  31. # ftSmallint SQL_SMALLINT
  32. # ftFloat SQL_DOUBLE
  33. # ftString SQL_CHAR
  34. # ftMemo SQL_BINARY // SQL_VARCHAR
  35. #
  36. type
  37. TSqlChar* = char
  38. TSqlSmallInt* = int16
  39. SqlUSmallInt* = int16
  40. SqlHandle* = pointer
  41. SqlHEnv* = SqlHandle
  42. SqlHDBC* = SqlHandle
  43. SqlHStmt* = SqlHandle
  44. SqlHDesc* = SqlHandle
  45. TSqlInteger* = int32
  46. SqlUInteger* = int32
  47. TSqlLen* = int
  48. TSqlULen* = uint
  49. SqlPointer* = pointer
  50. TSqlReal* = cfloat
  51. TSqlDouble* = cdouble
  52. TSqlFloat* = cdouble
  53. SqlHWND* = pointer
  54. PSQLCHAR* = cstring
  55. PSQLINTEGER* = ptr TSqlInteger
  56. PSQLUINTEGER* = ptr SqlUInteger
  57. PSQLSMALLINT* = ptr TSqlSmallInt
  58. PSQLUSMALLINT* = ptr SqlUSmallInt
  59. PSQLREAL* = ptr TSqlReal
  60. PSQLDOUBLE* = ptr TSqlDouble
  61. PSQLFLOAT* = ptr TSqlFloat
  62. PSQLHANDLE* = ptr SqlHandle
  63. const # SQL data type codes
  64. SQL_UNKNOWN_TYPE* = 0
  65. SQL_LONGVARCHAR* = (- 1)
  66. SQL_BINARY* = (- 2)
  67. SQL_VARBINARY* = (- 3)
  68. SQL_LONGVARBINARY* = (- 4)
  69. SQL_BIGINT* = (- 5)
  70. SQL_TINYINT* = (- 6)
  71. SQL_BIT* = (- 7)
  72. SQL_WCHAR* = (- 8)
  73. SQL_WVARCHAR* = (- 9)
  74. SQL_WLONGVARCHAR* = (- 10)
  75. SQL_CHAR* = 1
  76. SQL_NUMERIC* = 2
  77. SQL_DECIMAL* = 3
  78. SQL_INTEGER* = 4
  79. SQL_SMALLINT* = 5
  80. SQL_FLOAT* = 6
  81. SQL_REAL* = 7
  82. SQL_DOUBLE* = 8
  83. SQL_DATETIME* = 9
  84. SQL_VARCHAR* = 12
  85. SQL_TYPE_DATE* = 91
  86. SQL_TYPE_TIME* = 92
  87. SQL_TYPE_TIMESTAMP* = 93
  88. SQL_DATE* = 9
  89. SQL_TIME* = 10
  90. SQL_TIMESTAMP* = 11
  91. SQL_INTERVAL* = 10
  92. SQL_GUID* = - 11 # interval codes
  93. when ODBCVER >= 0x0300:
  94. const
  95. SQL_CODE_YEAR* = 1
  96. SQL_CODE_MONTH* = 2
  97. SQL_CODE_DAY* = 3
  98. SQL_CODE_HOUR* = 4
  99. SQL_CODE_MINUTE* = 5
  100. SQL_CODE_SECOND* = 6
  101. SQL_CODE_YEAR_TO_MONTH* = 7
  102. SQL_CODE_DAY_TO_HOUR* = 8
  103. SQL_CODE_DAY_TO_MINUTE* = 9
  104. SQL_CODE_DAY_TO_SECOND* = 10
  105. SQL_CODE_HOUR_TO_MINUTE* = 11
  106. SQL_CODE_HOUR_TO_SECOND* = 12
  107. SQL_CODE_MINUTE_TO_SECOND* = 13
  108. SQL_INTERVAL_YEAR* = 100 + SQL_CODE_YEAR
  109. SQL_INTERVAL_MONTH* = 100 + SQL_CODE_MONTH
  110. SQL_INTERVAL_DAY* = 100 + SQL_CODE_DAY
  111. SQL_INTERVAL_HOUR* = 100 + SQL_CODE_HOUR
  112. SQL_INTERVAL_MINUTE* = 100 + SQL_CODE_MINUTE
  113. SQL_INTERVAL_SECOND* = 100 + SQL_CODE_SECOND
  114. SQL_INTERVAL_YEAR_TO_MONTH* = 100 + SQL_CODE_YEAR_TO_MONTH
  115. SQL_INTERVAL_DAY_TO_HOUR* = 100 + SQL_CODE_DAY_TO_HOUR
  116. SQL_INTERVAL_DAY_TO_MINUTE* = 100 + SQL_CODE_DAY_TO_MINUTE
  117. SQL_INTERVAL_DAY_TO_SECOND* = 100 + SQL_CODE_DAY_TO_SECOND
  118. SQL_INTERVAL_HOUR_TO_MINUTE* = 100 + SQL_CODE_HOUR_TO_MINUTE
  119. SQL_INTERVAL_HOUR_TO_SECOND* = 100 + SQL_CODE_HOUR_TO_SECOND
  120. SQL_INTERVAL_MINUTE_TO_SECOND* = 100 + SQL_CODE_MINUTE_TO_SECOND
  121. else:
  122. const
  123. SQL_INTERVAL_YEAR* = - 80
  124. SQL_INTERVAL_MONTH* = - 81
  125. SQL_INTERVAL_YEAR_TO_MONTH* = - 82
  126. SQL_INTERVAL_DAY* = - 83
  127. SQL_INTERVAL_HOUR* = - 84
  128. SQL_INTERVAL_MINUTE* = - 85
  129. SQL_INTERVAL_SECOND* = - 86
  130. SQL_INTERVAL_DAY_TO_HOUR* = - 87
  131. SQL_INTERVAL_DAY_TO_MINUTE* = - 88
  132. SQL_INTERVAL_DAY_TO_SECOND* = - 89
  133. SQL_INTERVAL_HOUR_TO_MINUTE* = - 90
  134. SQL_INTERVAL_HOUR_TO_SECOND* = - 91
  135. SQL_INTERVAL_MINUTE_TO_SECOND* = - 92
  136. when ODBCVER < 0x0300:
  137. const
  138. SQL_UNICODE* = - 95
  139. SQL_UNICODE_VARCHAR* = - 96
  140. SQL_UNICODE_LONGVARCHAR* = - 97
  141. SQL_UNICODE_CHAR* = SQL_UNICODE
  142. else:
  143. # The previous definitions for SQL_UNICODE_ are historical and obsolete
  144. const
  145. SQL_UNICODE* = SQL_WCHAR
  146. SQL_UNICODE_VARCHAR* = SQL_WVARCHAR
  147. SQL_UNICODE_LONGVARCHAR* = SQL_WLONGVARCHAR
  148. SQL_UNICODE_CHAR* = SQL_WCHAR
  149. const # C datatype to SQL datatype mapping
  150. SQL_C_CHAR* = SQL_CHAR
  151. SQL_C_LONG* = SQL_INTEGER
  152. SQL_C_SHORT* = SQL_SMALLINT
  153. SQL_C_FLOAT* = SQL_REAL
  154. SQL_C_DOUBLE* = SQL_DOUBLE
  155. SQL_C_NUMERIC* = SQL_NUMERIC
  156. SQL_C_DEFAULT* = 99
  157. SQL_SIGNED_OFFSET* = - 20
  158. SQL_UNSIGNED_OFFSET* = - 22
  159. SQL_C_DATE* = SQL_DATE
  160. SQL_C_TIME* = SQL_TIME
  161. SQL_C_TIMESTAMP* = SQL_TIMESTAMP
  162. SQL_C_TYPE_DATE* = SQL_TYPE_DATE
  163. SQL_C_TYPE_TIME* = SQL_TYPE_TIME
  164. SQL_C_TYPE_TIMESTAMP* = SQL_TYPE_TIMESTAMP
  165. SQL_C_INTERVAL_YEAR* = SQL_INTERVAL_YEAR
  166. SQL_C_INTERVAL_MONTH* = SQL_INTERVAL_MONTH
  167. SQL_C_INTERVAL_DAY* = SQL_INTERVAL_DAY
  168. SQL_C_INTERVAL_HOUR* = SQL_INTERVAL_HOUR
  169. SQL_C_INTERVAL_MINUTE* = SQL_INTERVAL_MINUTE
  170. SQL_C_INTERVAL_SECOND* = SQL_INTERVAL_SECOND
  171. SQL_C_INTERVAL_YEAR_TO_MONTH* = SQL_INTERVAL_YEAR_TO_MONTH
  172. SQL_C_INTERVAL_DAY_TO_HOUR* = SQL_INTERVAL_DAY_TO_HOUR
  173. SQL_C_INTERVAL_DAY_TO_MINUTE* = SQL_INTERVAL_DAY_TO_MINUTE
  174. SQL_C_INTERVAL_DAY_TO_SECOND* = SQL_INTERVAL_DAY_TO_SECOND
  175. SQL_C_INTERVAL_HOUR_TO_MINUTE* = SQL_INTERVAL_HOUR_TO_MINUTE
  176. SQL_C_INTERVAL_HOUR_TO_SECOND* = SQL_INTERVAL_HOUR_TO_SECOND
  177. SQL_C_INTERVAL_MINUTE_TO_SECOND* = SQL_INTERVAL_MINUTE_TO_SECOND
  178. SQL_C_BINARY* = SQL_BINARY
  179. SQL_C_BIT* = SQL_BIT
  180. SQL_C_SBIGINT* = SQL_BIGINT + SQL_SIGNED_OFFSET # SIGNED BIGINT
  181. SQL_C_UBIGINT* = SQL_BIGINT + SQL_UNSIGNED_OFFSET # UNSIGNED BIGINT
  182. SQL_C_TINYINT* = SQL_TINYINT
  183. SQL_C_SLONG* = SQL_C_LONG + SQL_SIGNED_OFFSET # SIGNED INTEGER
  184. SQL_C_SSHORT* = SQL_C_SHORT + SQL_SIGNED_OFFSET # SIGNED SMALLINT
  185. SQL_C_STINYINT* = SQL_TINYINT + SQL_SIGNED_OFFSET # SIGNED TINYINT
  186. SQL_C_ULONG* = SQL_C_LONG + SQL_UNSIGNED_OFFSET # UNSIGNED INTEGER
  187. SQL_C_USHORT* = SQL_C_SHORT + SQL_UNSIGNED_OFFSET # UNSIGNED SMALLINT
  188. SQL_C_UTINYINT* = SQL_TINYINT + SQL_UNSIGNED_OFFSET # UNSIGNED TINYINT
  189. SQL_C_BOOKMARK* = SQL_C_ULONG # BOOKMARK
  190. SQL_C_GUID* = SQL_GUID
  191. SQL_TYPE_NULL* = 0
  192. when ODBCVER < 0x0300:
  193. const
  194. SQL_TYPE_MIN* = SQL_BIT
  195. SQL_TYPE_MAX* = SQL_VARCHAR
  196. const
  197. SQL_C_VARBOOKMARK* = SQL_C_BINARY
  198. SQL_API_SQLDESCRIBEPARAM* = 58
  199. SQL_NO_TOTAL* = - 4
  200. type
  201. SQL_DATE_STRUCT* {.final, pure.} = object
  202. Year*: TSqlSmallInt
  203. Month*: SqlUSmallInt
  204. Day*: SqlUSmallInt
  205. PSQL_DATE_STRUCT* = ptr SQL_DATE_STRUCT
  206. SQL_TIME_STRUCT* {.final, pure.} = object
  207. Hour*: SqlUSmallInt
  208. Minute*: SqlUSmallInt
  209. Second*: SqlUSmallInt
  210. PSQL_TIME_STRUCT* = ptr SQL_TIME_STRUCT
  211. SQL_TIMESTAMP_STRUCT* {.final, pure.} = object
  212. Year*: SqlUSmallInt
  213. Month*: SqlUSmallInt
  214. Day*: SqlUSmallInt
  215. Hour*: SqlUSmallInt
  216. Minute*: SqlUSmallInt
  217. Second*: SqlUSmallInt
  218. Fraction*: SqlUInteger
  219. PSQL_TIMESTAMP_STRUCT* = ptr SQL_TIMESTAMP_STRUCT
  220. const
  221. SQL_NAME_LEN* = 128
  222. SQL_OV_ODBC3* = 3
  223. SQL_OV_ODBC2* = 2
  224. SQL_ATTR_ODBC_VERSION* = 200 # Options for SQLDriverConnect
  225. SQL_DRIVER_NOPROMPT* = 0
  226. SQL_DRIVER_COMPLETE* = 1
  227. SQL_DRIVER_PROMPT* = 2
  228. SQL_DRIVER_COMPLETE_REQUIRED* = 3
  229. SQL_IS_POINTER* = (- 4) # whether an attribute is a pointer or not
  230. SQL_IS_UINTEGER* = (- 5)
  231. SQL_IS_INTEGER* = (- 6)
  232. SQL_IS_USMALLINT* = (- 7)
  233. SQL_IS_SMALLINT* = (- 8) # SQLExtendedFetch "fFetchType" values
  234. SQL_FETCH_BOOKMARK* = 8
  235. SQL_SCROLL_OPTIONS* = 44 # SQL_USE_BOOKMARKS options
  236. SQL_UB_OFF* = 0
  237. SQL_UB_ON* = 1
  238. SQL_UB_DEFAULT* = SQL_UB_OFF
  239. SQL_UB_FIXED* = SQL_UB_ON
  240. SQL_UB_VARIABLE* = 2 # SQL_SCROLL_OPTIONS masks
  241. SQL_SO_FORWARD_ONLY* = 0x00000001
  242. SQL_SO_KEYSET_DRIVEN* = 0x00000002
  243. SQL_SO_DYNAMIC* = 0x00000004
  244. SQL_SO_MIXED* = 0x00000008
  245. SQL_SO_STATIC* = 0x00000010
  246. SQL_BOOKMARK_PERSISTENCE* = 82
  247. SQL_STATIC_SENSITIVITY* = 83 # SQL_BOOKMARK_PERSISTENCE values
  248. SQL_BP_CLOSE* = 0x00000001
  249. SQL_BP_DELETE* = 0x00000002
  250. SQL_BP_DROP* = 0x00000004
  251. SQL_BP_TRANSACTION* = 0x00000008
  252. SQL_BP_UPDATE* = 0x00000010
  253. SQL_BP_OTHER_HSTMT* = 0x00000020
  254. SQL_BP_SCROLL* = 0x00000040
  255. SQL_DYNAMIC_CURSOR_ATTRIBUTES1* = 144
  256. SQL_DYNAMIC_CURSOR_ATTRIBUTES2* = 145
  257. SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES1* = 146
  258. SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2* = 147
  259. SQL_INDEX_KEYWORDS* = 148
  260. SQL_INFO_SCHEMA_VIEWS* = 149
  261. SQL_KEYSET_CURSOR_ATTRIBUTES1* = 150
  262. SQL_KEYSET_CURSOR_ATTRIBUTES2* = 151
  263. SQL_STATIC_CURSOR_ATTRIBUTES1* = 167
  264. SQL_STATIC_CURSOR_ATTRIBUTES2* = 168 # supported SQLFetchScroll FetchOrientation's
  265. SQL_CA1_NEXT* = 1
  266. SQL_CA1_ABSOLUTE* = 2
  267. SQL_CA1_RELATIVE* = 4
  268. SQL_CA1_BOOKMARK* = 8 # supported SQLSetPos LockType's
  269. SQL_CA1_LOCK_NO_CHANGE* = 0x00000040
  270. SQL_CA1_LOCK_EXCLUSIVE* = 0x00000080
  271. SQL_CA1_LOCK_UNLOCK* = 0x00000100 # supported SQLSetPos Operations
  272. SQL_CA1_POS_POSITION* = 0x00000200
  273. SQL_CA1_POS_UPDATE* = 0x00000400
  274. SQL_CA1_POS_DELETE* = 0x00000800
  275. SQL_CA1_POS_REFRESH* = 0x00001000 # positioned updates and deletes
  276. SQL_CA1_POSITIONED_UPDATE* = 0x00002000
  277. SQL_CA1_POSITIONED_DELETE* = 0x00004000
  278. SQL_CA1_SELECT_FOR_UPDATE* = 0x00008000 # supported SQLBulkOperations operations
  279. SQL_CA1_BULK_ADD* = 0x00010000
  280. SQL_CA1_BULK_UPDATE_BY_BOOKMARK* = 0x00020000
  281. SQL_CA1_BULK_DELETE_BY_BOOKMARK* = 0x00040000
  282. SQL_CA1_BULK_FETCH_BY_BOOKMARK* = 0x00080000 # supported values for SQL_ATTR_SCROLL_CONCURRENCY
  283. SQL_CA2_READ_ONLY_CONCURRENCY* = 1
  284. SQL_CA2_LOCK_CONCURRENCY* = 2
  285. SQL_CA2_OPT_ROWVER_CONCURRENCY* = 4
  286. SQL_CA2_OPT_VALUES_CONCURRENCY* = 8 # sensitivity of the cursor to its own inserts, deletes, and updates
  287. SQL_CA2_SENSITIVITY_ADDITIONS* = 0x00000010
  288. SQL_CA2_SENSITIVITY_DELETIONS* = 0x00000020
  289. SQL_CA2_SENSITIVITY_UPDATES* = 0x00000040 # semantics of SQL_ATTR_MAX_ROWS
  290. SQL_CA2_MAX_ROWS_SELECT* = 0x00000080
  291. SQL_CA2_MAX_ROWS_INSERT* = 0x00000100
  292. SQL_CA2_MAX_ROWS_DELETE* = 0x00000200
  293. SQL_CA2_MAX_ROWS_UPDATE* = 0x00000400
  294. SQL_CA2_MAX_ROWS_CATALOG* = 0x00000800
  295. SQL_CA2_MAX_ROWS_AFFECTS_ALL* = (SQL_CA2_MAX_ROWS_SELECT or
  296. SQL_CA2_MAX_ROWS_INSERT or SQL_CA2_MAX_ROWS_DELETE or
  297. SQL_CA2_MAX_ROWS_UPDATE or SQL_CA2_MAX_ROWS_CATALOG) # semantics of
  298. # SQL_DIAG_CURSOR_ROW_COUNT
  299. SQL_CA2_CRC_EXACT* = 0x00001000
  300. SQL_CA2_CRC_APPROXIMATE* = 0x00002000 # the kinds of positioned statements that can be simulated
  301. SQL_CA2_SIMULATE_NON_UNIQUE* = 0x00004000
  302. SQL_CA2_SIMULATE_TRY_UNIQUE* = 0x00008000
  303. SQL_CA2_SIMULATE_UNIQUE* = 0x00010000 # Operations in SQLBulkOperations
  304. SQL_ADD* = 4
  305. SQL_SETPOS_MAX_OPTION_VALUE* = SQL_ADD
  306. SQL_UPDATE_BY_BOOKMARK* = 5
  307. SQL_DELETE_BY_BOOKMARK* = 6
  308. SQL_FETCH_BY_BOOKMARK* = 7 # Operations in SQLSetPos
  309. SQL_POSITION* = 0
  310. SQL_REFRESH* = 1
  311. SQL_UPDATE* = 2
  312. SQL_DELETE* = 3 # Lock options in SQLSetPos
  313. SQL_LOCK_NO_CHANGE* = 0
  314. SQL_LOCK_EXCLUSIVE* = 1
  315. SQL_LOCK_UNLOCK* = 2 # SQLExtendedFetch "rgfRowStatus" element values
  316. SQL_ROW_SUCCESS* = 0
  317. SQL_ROW_DELETED* = 1
  318. SQL_ROW_UPDATED* = 2
  319. SQL_ROW_NOROW* = 3
  320. SQL_ROW_ADDED* = 4
  321. SQL_ROW_ERROR* = 5
  322. SQL_ROW_SUCCESS_WITH_INFO* = 6
  323. SQL_ROW_PROCEED* = 0
  324. SQL_ROW_IGNORE* = 1
  325. SQL_MAX_DSN_LENGTH* = 32 # maximum data source name size
  326. SQL_MAX_OPTION_STRING_LENGTH* = 256
  327. SQL_ODBC_CURSORS* = 110
  328. SQL_ATTR_ODBC_CURSORS* = SQL_ODBC_CURSORS # SQL_ODBC_CURSORS options
  329. SQL_CUR_USE_IF_NEEDED* = 0
  330. SQL_CUR_USE_ODBC* = 1
  331. SQL_CUR_USE_DRIVER* = 2
  332. SQL_CUR_DEFAULT* = SQL_CUR_USE_DRIVER
  333. SQL_PARAM_TYPE_UNKNOWN* = 0
  334. SQL_PARAM_INPUT* = 1
  335. SQL_PARAM_INPUT_OUTPUT* = 2
  336. SQL_RESULT_COL* = 3
  337. SQL_PARAM_OUTPUT* = 4
  338. SQL_RETURN_VALUE* = 5 # special length/indicator values
  339. SQL_NULL_DATA* = (- 1)
  340. SQL_DATA_AT_EXEC* = (- 2)
  341. SQL_SUCCESS* = 0
  342. SQL_SUCCESS_WITH_INFO* = 1
  343. SQL_NO_DATA* = 100
  344. SQL_ERROR* = (- 1)
  345. SQL_INVALID_HANDLE* = (- 2)
  346. SQL_STILL_EXECUTING* = 2
  347. SQL_NEED_DATA* = 99 # flags for null-terminated string
  348. SQL_NTS* = (- 3) # maximum message length
  349. SQL_MAX_MESSAGE_LENGTH* = 512 # date/time length constants
  350. SQL_DATE_LEN* = 10
  351. SQL_TIME_LEN* = 8 # add P+1 if precision is nonzero
  352. SQL_TIMESTAMP_LEN* = 19 # add P+1 if precision is nonzero
  353. # handle type identifiers
  354. SQL_HANDLE_ENV* = 1
  355. SQL_HANDLE_DBC* = 2
  356. SQL_HANDLE_STMT* = 3
  357. SQL_HANDLE_DESC* = 4 # environment attribute
  358. SQL_ATTR_OUTPUT_NTS* = 10001 # connection attributes
  359. SQL_ATTR_AUTO_IPD* = 10001
  360. SQL_ATTR_METADATA_ID* = 10014 # statement attributes
  361. SQL_ATTR_APP_ROW_DESC* = 10010
  362. SQL_ATTR_APP_PARAM_DESC* = 10011
  363. SQL_ATTR_IMP_ROW_DESC* = 10012
  364. SQL_ATTR_IMP_PARAM_DESC* = 10013
  365. SQL_ATTR_CURSOR_SCROLLABLE* = (- 1)
  366. SQL_ATTR_CURSOR_SENSITIVITY* = (- 2)
  367. SQL_QUERY_TIMEOUT* = 0
  368. SQL_MAX_ROWS* = 1
  369. SQL_NOSCAN* = 2
  370. SQL_MAX_LENGTH* = 3
  371. SQL_ASYNC_ENABLE* = 4 # same as SQL_ATTR_ASYNC_ENABLE */
  372. SQL_BIND_TYPE* = 5
  373. SQL_CURSOR_TYPE* = 6
  374. SQL_CONCURRENCY* = 7
  375. SQL_KEYSET_SIZE* = 8
  376. SQL_ROWSET_SIZE* = 9
  377. SQL_SIMULATE_CURSOR* = 10
  378. SQL_RETRIEVE_DATA* = 11
  379. SQL_USE_BOOKMARKS* = 12
  380. SQL_GET_BOOKMARK* = 13 # GetStmtOption Only */
  381. SQL_ROW_NUMBER* = 14 # GetStmtOption Only */
  382. SQL_ATTR_CURSOR_TYPE* = SQL_CURSOR_TYPE
  383. SQL_ATTR_CONCURRENCY* = SQL_CONCURRENCY
  384. SQL_ATTR_FETCH_BOOKMARK_PTR* = 16
  385. SQL_ATTR_ROW_STATUS_PTR* = 25
  386. SQL_ATTR_ROWS_FETCHED_PTR* = 26
  387. SQL_AUTOCOMMIT* = 102
  388. SQL_ATTR_AUTOCOMMIT* = SQL_AUTOCOMMIT
  389. SQL_ATTR_ROW_NUMBER* = SQL_ROW_NUMBER
  390. SQL_TXN_ISOLATION* = 108
  391. SQL_ATTR_TXN_ISOLATION* = SQL_TXN_ISOLATION
  392. SQL_ATTR_MAX_ROWS* = SQL_MAX_ROWS
  393. SQL_ATTR_USE_BOOKMARKS* = SQL_USE_BOOKMARKS #* connection attributes */
  394. SQL_ACCESS_MODE* = 101 # SQL_AUTOCOMMIT =102;
  395. SQL_LOGIN_TIMEOUT* = 103
  396. SQL_OPT_TRACE* = 104
  397. SQL_OPT_TRACEFILE* = 105
  398. SQL_TRANSLATE_DLL* = 106
  399. SQL_TRANSLATE_OPTION* = 107 # SQL_TXN_ISOLATION =108;
  400. SQL_CURRENT_QUALIFIER* = 109 # SQL_ODBC_CURSORS =110;
  401. SQL_QUIET_MODE* = 111
  402. SQL_PACKET_SIZE* = 112 #* connection attributes with new names */
  403. SQL_ATTR_ACCESS_MODE* = SQL_ACCESS_MODE # SQL_ATTR_AUTOCOMMIT =SQL_AUTOCOMMIT;
  404. SQL_ATTR_CONNECTION_DEAD* = 1209 #* GetConnectAttr only */
  405. SQL_ATTR_CONNECTION_TIMEOUT* = 113
  406. SQL_ATTR_CURRENT_CATALOG* = SQL_CURRENT_QUALIFIER
  407. SQL_ATTR_DISCONNECT_BEHAVIOR* = 114
  408. SQL_ATTR_ENLIST_IN_DTC* = 1207
  409. SQL_ATTR_ENLIST_IN_XA* = 1208
  410. SQL_ATTR_LOGIN_TIMEOUT* = SQL_LOGIN_TIMEOUT # SQL_ATTR_ODBC_CURSORS =SQL_ODBC_CURSORS;
  411. SQL_ATTR_PACKET_SIZE* = SQL_PACKET_SIZE
  412. SQL_ATTR_QUIET_MODE* = SQL_QUIET_MODE
  413. SQL_ATTR_TRACE* = SQL_OPT_TRACE
  414. SQL_ATTR_TRACEFILE* = SQL_OPT_TRACEFILE
  415. SQL_ATTR_TRANSLATE_LIB* = SQL_TRANSLATE_DLL
  416. SQL_ATTR_TRANSLATE_OPTION* = SQL_TRANSLATE_OPTION # SQL_ATTR_TXN_ISOLATION =SQL_TXN_ISOLATION;
  417. #* SQL_ACCESS_MODE options */
  418. SQL_MODE_READ_WRITE* = 0
  419. SQL_MODE_READ_ONLY* = 1
  420. SQL_MODE_DEFAULT* = SQL_MODE_READ_WRITE #* SQL_AUTOCOMMIT options */
  421. SQL_AUTOCOMMIT_OFF* = 0
  422. SQL_AUTOCOMMIT_ON* = 1
  423. SQL_AUTOCOMMIT_DEFAULT* = SQL_AUTOCOMMIT_ON # SQL_ATTR_CURSOR_SCROLLABLE values
  424. SQL_NONSCROLLABLE* = 0
  425. SQL_SCROLLABLE* = 1 # SQL_CURSOR_TYPE options
  426. SQL_CURSOR_FORWARD_ONLY* = 0
  427. SQL_CURSOR_KEYSET_DRIVEN* = 1
  428. SQL_CURSOR_DYNAMIC* = 2
  429. SQL_CURSOR_STATIC* = 3
  430. SQL_CURSOR_TYPE_DEFAULT* = SQL_CURSOR_FORWARD_ONLY # Default value
  431. # SQL_CONCURRENCY options
  432. SQL_CONCUR_READ_ONLY* = 1
  433. SQL_CONCUR_LOCK* = 2
  434. SQL_CONCUR_ROWVER* = 3
  435. SQL_CONCUR_VALUES* = 4
  436. SQL_CONCUR_DEFAULT* = SQL_CONCUR_READ_ONLY # Default value
  437. # identifiers of fields in the SQL descriptor
  438. SQL_DESC_COUNT* = 1001
  439. SQL_DESC_TYPE* = 1002
  440. SQL_DESC_LENGTH* = 1003
  441. SQL_DESC_OCTET_LENGTH_PTR* = 1004
  442. SQL_DESC_PRECISION* = 1005
  443. SQL_DESC_SCALE* = 1006
  444. SQL_DESC_DATETIME_INTERVAL_CODE* = 1007
  445. SQL_DESC_NULLABLE* = 1008
  446. SQL_DESC_INDICATOR_PTR* = 1009
  447. SQL_DESC_DATA_PTR* = 1010
  448. SQL_DESC_NAME* = 1011
  449. SQL_DESC_UNNAMED* = 1012
  450. SQL_DESC_OCTET_LENGTH* = 1013
  451. SQL_DESC_ALLOC_TYPE* = 1099 # identifiers of fields in the diagnostics area
  452. SQL_DIAG_RETURNCODE* = 1
  453. SQL_DIAG_NUMBER* = 2
  454. SQL_DIAG_ROW_COUNT* = 3
  455. SQL_DIAG_SQLSTATE* = 4
  456. SQL_DIAG_NATIVE* = 5
  457. SQL_DIAG_MESSAGE_TEXT* = 6
  458. SQL_DIAG_DYNAMIC_FUNCTION* = 7
  459. SQL_DIAG_CLASS_ORIGIN* = 8
  460. SQL_DIAG_SUBCLASS_ORIGIN* = 9
  461. SQL_DIAG_CONNECTION_NAME* = 10
  462. SQL_DIAG_SERVER_NAME* = 11
  463. SQL_DIAG_DYNAMIC_FUNCTION_CODE* = 12 # dynamic function codes
  464. SQL_DIAG_ALTER_TABLE* = 4
  465. SQL_DIAG_CREATE_INDEX* = (- 1)
  466. SQL_DIAG_CREATE_TABLE* = 77
  467. SQL_DIAG_CREATE_VIEW* = 84
  468. SQL_DIAG_DELETE_WHERE* = 19
  469. SQL_DIAG_DROP_INDEX* = (- 2)
  470. SQL_DIAG_DROP_TABLE* = 32
  471. SQL_DIAG_DROP_VIEW* = 36
  472. SQL_DIAG_DYNAMIC_DELETE_CURSOR* = 38
  473. SQL_DIAG_DYNAMIC_UPDATE_CURSOR* = 81
  474. SQL_DIAG_GRANT* = 48
  475. SQL_DIAG_INSERT* = 50
  476. SQL_DIAG_REVOKE* = 59
  477. SQL_DIAG_SELECT_CURSOR* = 85
  478. SQL_DIAG_UNKNOWN_STATEMENT* = 0
  479. SQL_DIAG_UPDATE_WHERE* = 82 # Statement attribute values for cursor sensitivity
  480. SQL_UNSPECIFIED* = 0
  481. SQL_INSENSITIVE* = 1
  482. SQL_SENSITIVE* = 2 # GetTypeInfo() request for all data types
  483. SQL_ALL_TYPES* = 0 # Default conversion code for SQLBindCol(), SQLBindParam() and SQLGetData()
  484. SQL_DEFAULT* = 99 # SQLGetData() code indicating that the application row descriptor
  485. # specifies the data type
  486. SQL_ARD_TYPE* = (- 99) # SQL date/time type subcodes
  487. SQL_CODE_DATE* = 1
  488. SQL_CODE_TIME* = 2
  489. SQL_CODE_TIMESTAMP* = 3 # CLI option values
  490. SQL_FALSE* = 0
  491. SQL_TRUE* = 1 # values of NULLABLE field in descriptor
  492. SQL_NO_NULLS* = 0
  493. SQL_NULLABLE* = 1 # Value returned by SQLGetTypeInfo() to denote that it is
  494. # not known whether or not a data type supports null values.
  495. SQL_NULLABLE_UNKNOWN* = 2
  496. SQL_CLOSE* = 0
  497. SQL_DROP* = 1
  498. SQL_UNBIND* = 2
  499. SQL_RESET_PARAMS* = 3 # Codes used for FetchOrientation in SQLFetchScroll(),
  500. # and in SQLDataSources()
  501. SQL_FETCH_NEXT* = 1
  502. SQL_FETCH_FIRST* = 2
  503. SQL_FETCH_FIRST_USER* = 31
  504. SQL_FETCH_FIRST_SYSTEM* = 32 # Other codes used for FetchOrientation in SQLFetchScroll()
  505. SQL_FETCH_LAST* = 3
  506. SQL_FETCH_PRIOR* = 4
  507. SQL_FETCH_ABSOLUTE* = 5
  508. SQL_FETCH_RELATIVE* = 6
  509. SQL_NULL_HENV* = SqlHEnv(nil)
  510. SQL_NULL_HDBC* = SqlHDBC(nil)
  511. SQL_NULL_HSTMT* = SqlHStmt(nil)
  512. SQL_NULL_HDESC* = SqlHDesc(nil) #* null handle used in place of parent handle when allocating HENV */
  513. SQL_NULL_HANDLE* = SqlHandle(nil) #* Values that may appear in the result set of SQLSpecialColumns() */
  514. SQL_SCOPE_CURROW* = 0
  515. SQL_SCOPE_TRANSACTION* = 1
  516. SQL_SCOPE_SESSION* = 2 #* Column types and scopes in SQLSpecialColumns. */
  517. SQL_BEST_ROWID* = 1
  518. SQL_ROWVER* = 2
  519. SQL_ROW_IDENTIFIER* = 1 #* Reserved values for UNIQUE argument of SQLStatistics() */
  520. SQL_INDEX_UNIQUE* = 0
  521. SQL_INDEX_ALL* = 1 #* Reserved values for RESERVED argument of SQLStatistics() */
  522. SQL_QUICK* = 0
  523. SQL_ENSURE* = 1 #* Values that may appear in the result set of SQLStatistics() */
  524. SQL_TABLE_STAT* = 0
  525. SQL_INDEX_CLUSTERED* = 1
  526. SQL_INDEX_HASHED* = 2
  527. SQL_INDEX_OTHER* = 3
  528. SQL_SCROLL_CONCURRENCY* = 43
  529. SQL_TXN_CAPABLE* = 46
  530. SQL_TRANSACTION_CAPABLE* = SQL_TXN_CAPABLE
  531. SQL_USER_NAME* = 47
  532. SQL_TXN_ISOLATION_OPTION* = 72
  533. SQL_TRANSACTION_ISOLATION_OPTION* = SQL_TXN_ISOLATION_OPTION
  534. SQL_OJ_CAPABILITIES* = 115
  535. SQL_OUTER_JOIN_CAPABILITIES* = SQL_OJ_CAPABILITIES
  536. SQL_XOPEN_CLI_YEAR* = 10000
  537. SQL_CURSOR_SENSITIVITY* = 10001
  538. SQL_DESCRIBE_PARAMETER* = 10002
  539. SQL_CATALOG_NAME* = 10003
  540. SQL_COLLATION_SEQ* = 10004
  541. SQL_MAX_IDENTIFIER_LEN* = 10005
  542. SQL_MAXIMUM_IDENTIFIER_LENGTH* = SQL_MAX_IDENTIFIER_LEN
  543. SQL_SCCO_READ_ONLY* = 1
  544. SQL_SCCO_LOCK* = 2
  545. SQL_SCCO_OPT_ROWVER* = 4
  546. SQL_SCCO_OPT_VALUES* = 8 #* SQL_TXN_CAPABLE values */
  547. SQL_TC_NONE* = 0
  548. SQL_TC_DML* = 1
  549. SQL_TC_ALL* = 2
  550. SQL_TC_DDL_COMMIT* = 3
  551. SQL_TC_DDL_IGNORE* = 4 #* SQL_TXN_ISOLATION_OPTION bitmasks */
  552. SQL_TXN_READ_UNCOMMITTED* = 1
  553. SQL_TRANSACTION_READ_UNCOMMITTED* = SQL_TXN_READ_UNCOMMITTED
  554. SQL_TXN_READ_COMMITTED* = 2
  555. SQL_TRANSACTION_READ_COMMITTED* = SQL_TXN_READ_COMMITTED
  556. SQL_TXN_REPEATABLE_READ* = 4
  557. SQL_TRANSACTION_REPEATABLE_READ* = SQL_TXN_REPEATABLE_READ
  558. SQL_TXN_SERIALIZABLE* = 8
  559. SQL_TRANSACTION_SERIALIZABLE* = SQL_TXN_SERIALIZABLE
  560. SQL_SS_ADDITIONS* = 1
  561. SQL_SS_DELETIONS* = 2
  562. SQL_SS_UPDATES* = 4 # SQLColAttributes defines
  563. SQL_COLUMN_COUNT* = 0
  564. SQL_COLUMN_NAME* = 1
  565. SQL_COLUMN_TYPE* = 2
  566. SQL_COLUMN_LENGTH* = 3
  567. SQL_COLUMN_PRECISION* = 4
  568. SQL_COLUMN_SCALE* = 5
  569. SQL_COLUMN_DISPLAY_SIZE* = 6
  570. SQL_COLUMN_NULLABLE* = 7
  571. SQL_COLUMN_UNSIGNED* = 8
  572. SQL_COLUMN_MONEY* = 9
  573. SQL_COLUMN_UPDATABLE* = 10
  574. SQL_COLUMN_AUTO_INCREMENT* = 11
  575. SQL_COLUMN_CASE_SENSITIVE* = 12
  576. SQL_COLUMN_SEARCHABLE* = 13
  577. SQL_COLUMN_TYPE_NAME* = 14
  578. SQL_COLUMN_TABLE_NAME* = 15
  579. SQL_COLUMN_OWNER_NAME* = 16
  580. SQL_COLUMN_QUALIFIER_NAME* = 17
  581. SQL_COLUMN_LABEL* = 18
  582. SQL_COLATT_OPT_MAX* = SQL_COLUMN_LABEL
  583. SQL_COLUMN_DRIVER_START* = 1000
  584. SQL_DESC_ARRAY_SIZE* = 20
  585. SQL_DESC_ARRAY_STATUS_PTR* = 21
  586. SQL_DESC_AUTO_UNIQUE_VALUE* = SQL_COLUMN_AUTO_INCREMENT
  587. SQL_DESC_BASE_COLUMN_NAME* = 22
  588. SQL_DESC_BASE_TABLE_NAME* = 23
  589. SQL_DESC_BIND_OFFSET_PTR* = 24
  590. SQL_DESC_BIND_TYPE* = 25
  591. SQL_DESC_CASE_SENSITIVE* = SQL_COLUMN_CASE_SENSITIVE
  592. SQL_DESC_CATALOG_NAME* = SQL_COLUMN_QUALIFIER_NAME
  593. SQL_DESC_CONCISE_TYPE* = SQL_COLUMN_TYPE
  594. SQL_DESC_DATETIME_INTERVAL_PRECISION* = 26
  595. SQL_DESC_DISPLAY_SIZE* = SQL_COLUMN_DISPLAY_SIZE
  596. SQL_DESC_FIXED_PREC_SCALE* = SQL_COLUMN_MONEY
  597. SQL_DESC_LABEL* = SQL_COLUMN_LABEL
  598. SQL_DESC_LITERAL_PREFIX* = 27
  599. SQL_DESC_LITERAL_SUFFIX* = 28
  600. SQL_DESC_LOCAL_TYPE_NAME* = 29
  601. SQL_DESC_MAXIMUM_SCALE* = 30
  602. SQL_DESC_MINIMUM_SCALE* = 31
  603. SQL_DESC_NUM_PREC_RADIX* = 32
  604. SQL_DESC_PARAMETER_TYPE* = 33
  605. SQL_DESC_ROWS_PROCESSED_PTR* = 34
  606. SQL_DESC_SCHEMA_NAME* = SQL_COLUMN_OWNER_NAME
  607. SQL_DESC_SEARCHABLE* = SQL_COLUMN_SEARCHABLE
  608. SQL_DESC_TYPE_NAME* = SQL_COLUMN_TYPE_NAME
  609. SQL_DESC_TABLE_NAME* = SQL_COLUMN_TABLE_NAME
  610. SQL_DESC_UNSIGNED* = SQL_COLUMN_UNSIGNED
  611. SQL_DESC_UPDATABLE* = SQL_COLUMN_UPDATABLE #* SQLEndTran() options */
  612. SQL_COMMIT* = 0
  613. SQL_ROLLBACK* = 1
  614. SQL_ATTR_ROW_ARRAY_SIZE* = 27 #* SQLConfigDataSource() options */
  615. ODBC_ADD_DSN* = 1
  616. ODBC_CONFIG_DSN* = 2
  617. ODBC_REMOVE_DSN* = 3
  618. ODBC_ADD_SYS_DSN* = 4
  619. ODBC_CONFIG_SYS_DSN* = 5
  620. ODBC_REMOVE_SYS_DSN* = 6
  621. SQL_ACTIVE_CONNECTIONS* = 0 # SQLGetInfo
  622. SQL_DATA_SOURCE_NAME* = 2
  623. SQL_DATA_SOURCE_READ_ONLY* = 25
  624. SQL_DATABASE_NAME* = 2
  625. SQL_DBMS_NAME* = 17
  626. SQL_DBMS_VERSION* = 18
  627. SQL_DRIVER_HDBC* = 3
  628. SQL_DRIVER_HENV* = 4
  629. SQL_DRIVER_HSTMT* = 5
  630. SQL_DRIVER_NAME* = 6
  631. SQL_DRIVER_VER* = 7
  632. SQL_FETCH_DIRECTION* = 8
  633. SQL_ODBC_VER* = 10
  634. SQL_DRIVER_ODBC_VER* = 77
  635. SQL_SERVER_NAME* = 13
  636. SQL_ACTIVE_ENVIRONMENTS* = 116
  637. SQL_ACTIVE_STATEMENTS* = 1
  638. SQL_SQL_CONFORMANCE* = 118
  639. SQL_DATETIME_LITERALS* = 119
  640. SQL_ASYNC_MODE* = 10021
  641. SQL_BATCH_ROW_COUNT* = 120
  642. SQL_BATCH_SUPPORT* = 121
  643. SQL_CATALOG_LOCATION* = 114
  644. #SQL_CATALOG_NAME* = 10003
  645. SQL_CATALOG_NAME_SEPARATOR* = 41
  646. SQL_CATALOG_TERM* = 42
  647. SQL_CATALOG_USAGE* = 92
  648. #SQL_COLLATION_SEQ* = 10004
  649. SQL_COLUMN_ALIAS* = 87
  650. #SQL_USER_NAME* = 47
  651. proc SQLAllocHandle*(HandleType: TSqlSmallInt, InputHandle: SqlHandle,
  652. OutputHandlePtr: var SqlHandle): TSqlSmallInt{.
  653. dynlib: odbclib, importc.}
  654. proc SQLSetEnvAttr*(EnvironmentHandle: SqlHEnv, Attribute: TSqlInteger,
  655. Value: SqlPointer, StringLength: TSqlInteger): TSqlSmallInt{.
  656. dynlib: odbclib, importc.}
  657. proc SQLGetEnvAttr*(EnvironmentHandle: SqlHEnv, Attribute: TSqlInteger,
  658. Value: SqlPointer, BufferLength: TSqlInteger,
  659. StringLength: PSQLINTEGER): TSqlSmallInt{.dynlib: odbclib,
  660. importc.}
  661. proc SQLFreeHandle*(HandleType: TSqlSmallInt, Handle: SqlHandle): TSqlSmallInt{.
  662. dynlib: odbclib, importc.}
  663. proc SQLGetDiagRec*(HandleType: TSqlSmallInt, Handle: SqlHandle,
  664. RecNumber: TSqlSmallInt, Sqlstate: PSQLCHAR,
  665. NativeError: var TSqlInteger, MessageText: PSQLCHAR,
  666. BufferLength: TSqlSmallInt, TextLength: var TSqlSmallInt): TSqlSmallInt{.
  667. dynlib: odbclib, importc.}
  668. proc SQLGetDiagField*(HandleType: TSqlSmallInt, Handle: SqlHandle,
  669. RecNumber: TSqlSmallInt, DiagIdentifier: TSqlSmallInt,
  670. DiagInfoPtr: SqlPointer, BufferLength: TSqlSmallInt,
  671. StringLengthPtr: var TSqlSmallInt): TSqlSmallInt{.
  672. dynlib: odbclib, importc.}
  673. proc SQLConnect*(ConnectionHandle: SqlHDBC, ServerName: PSQLCHAR,
  674. NameLength1: TSqlSmallInt, UserName: PSQLCHAR,
  675. NameLength2: TSqlSmallInt, Authentication: PSQLCHAR,
  676. NameLength3: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib, importc.}
  677. proc SQLDisconnect*(ConnectionHandle: SqlHDBC): TSqlSmallInt{.dynlib: odbclib,
  678. importc.}
  679. proc SQLDriverConnect*(hdbc: SqlHDBC, hwnd: SqlHWND, szCsin: cstring,
  680. szCLen: TSqlSmallInt, szCsout: cstring,
  681. cbCSMax: TSqlSmallInt, cbCsOut: var TSqlSmallInt,
  682. f: SqlUSmallInt): TSqlSmallInt{.dynlib: odbclib, importc.}
  683. proc SQLBrowseConnect*(hdbc: SqlHDBC, szConnStrIn: PSQLCHAR,
  684. cbConnStrIn: TSqlSmallInt, szConnStrOut: PSQLCHAR,
  685. cbConnStrOutMax: TSqlSmallInt,
  686. cbConnStrOut: var TSqlSmallInt): TSqlSmallInt{.
  687. dynlib: odbclib, importc.}
  688. proc SQLExecDirect*(StatementHandle: SqlHStmt, StatementText: PSQLCHAR,
  689. TextLength: TSqlInteger): TSqlSmallInt{.dynlib: odbclib, importc.}
  690. proc SQLExecDirectW*(StatementHandle: SqlHStmt, StatementText: WideCString,
  691. TextLength: TSqlInteger): TSqlSmallInt{.dynlib: odbclib, importc.}
  692. proc SQLPrepare*(StatementHandle: SqlHStmt, StatementText: PSQLCHAR,
  693. TextLength: TSqlInteger): TSqlSmallInt{.dynlib: odbclib, importc.}
  694. proc SQLPrepareW*(StatementHandle: SqlHStmt, StatementText: WideCString,
  695. TextLength: TSqlInteger): TSqlSmallInt{.dynlib: odbclib, importc.}
  696. proc SQLCloseCursor*(StatementHandle: SqlHStmt): TSqlSmallInt{.dynlib: odbclib,
  697. importc.}
  698. proc SQLExecute*(StatementHandle: SqlHStmt): TSqlSmallInt{.dynlib: odbclib, importc.}
  699. proc SQLFetch*(StatementHandle: SqlHStmt): TSqlSmallInt{.dynlib: odbclib, importc.}
  700. proc SQLNumResultCols*(StatementHandle: SqlHStmt, ColumnCount: var TSqlSmallInt): TSqlSmallInt{.
  701. dynlib: odbclib, importc.}
  702. proc SQLDescribeCol*(StatementHandle: SqlHStmt, ColumnNumber: SqlUSmallInt,
  703. ColumnName: PSQLCHAR, BufferLength: TSqlSmallInt,
  704. NameLength: var TSqlSmallInt, DataType: var TSqlSmallInt,
  705. ColumnSize: var TSqlULen,
  706. DecimalDigits: var TSqlSmallInt, Nullable: var TSqlSmallInt): TSqlSmallInt{.
  707. dynlib: odbclib, importc.}
  708. proc SQLFetchScroll*(StatementHandle: SqlHStmt, FetchOrientation: TSqlSmallInt,
  709. FetchOffset: TSqlLen): TSqlSmallInt{.dynlib: odbclib,
  710. importc.}
  711. proc SQLExtendedFetch*(hstmt: SqlHStmt, fFetchType: SqlUSmallInt,
  712. irow: TSqlLen, pcrow: var TSqlULen,
  713. rgfRowStatus: PSQLUSMALLINT): TSqlSmallInt{.dynlib: odbclib,
  714. importc.}
  715. proc SQLGetData*(StatementHandle: SqlHStmt, ColumnNumber: SqlUSmallInt,
  716. TargetType: TSqlSmallInt, TargetValue: SqlPointer,
  717. BufferLength: TSqlLen, StrLen_or_Ind: ptr TSqlLen): TSqlSmallInt{.
  718. dynlib: odbclib, importc.}
  719. proc SQLSetStmtAttr*(StatementHandle: SqlHStmt, Attribute: TSqlInteger,
  720. Value: SqlPointer, StringLength: TSqlInteger): TSqlSmallInt{.
  721. dynlib: odbclib, importc.}
  722. proc SQLGetStmtAttr*(StatementHandle: SqlHStmt, Attribute: TSqlInteger,
  723. Value: SqlPointer, BufferLength: TSqlInteger,
  724. StringLength: PSQLINTEGER): TSqlSmallInt{.dynlib: odbclib,
  725. importc.}
  726. proc SQLGetInfo*(ConnectionHandle: SqlHDBC, InfoType: SqlUSmallInt,
  727. InfoValue: SqlPointer, BufferLength: TSqlSmallInt,
  728. StringLength: PSQLSMALLINT): TSqlSmallInt{.dynlib: odbclib,
  729. importc.}
  730. proc SQLBulkOperations*(StatementHandle: SqlHStmt, Operation: SqlUSmallInt): TSqlSmallInt{.
  731. dynlib: odbclib, importc.}
  732. proc SQLPutData*(StatementHandle: SqlHStmt, Data: SqlPointer,
  733. StrLen_or_Ind: TSQLLEN): TSqlSmallInt{.dynlib: odbclib, importc.}
  734. proc SQLBindCol*(StatementHandle: SqlHStmt, ColumnNumber: SqlUSmallInt,
  735. TargetType: TSqlSmallInt, TargetValue: SqlPointer,
  736. BufferLength: TSqlLEN, StrLen_or_Ind: PSQLINTEGER): TSqlSmallInt{.
  737. dynlib: odbclib, importc.}
  738. proc SQLSetPos*(hstmt: SqlHStmt, irow: SqlUSmallInt, fOption: SqlUSmallInt,
  739. fLock: SqlUSmallInt): TSqlSmallInt{.dynlib: odbclib, importc.}
  740. proc SQLDataSources*(EnvironmentHandle: SqlHEnv, Direction: SqlUSmallInt,
  741. ServerName: PSQLCHAR, BufferLength1: TSqlSmallInt,
  742. NameLength1: PSQLSMALLINT, Description: PSQLCHAR,
  743. BufferLength2: TSqlSmallInt, NameLength2: PSQLSMALLINT): TSqlSmallInt{.
  744. dynlib: odbclib, importc.}
  745. proc SQLDrivers*(EnvironmentHandle: SqlHEnv, Direction: SqlUSmallInt,
  746. DriverDescription: PSQLCHAR, BufferLength1: TSqlSmallInt,
  747. DescriptionLength1: PSQLSMALLINT, DriverAttributes: PSQLCHAR,
  748. BufferLength2: TSqlSmallInt, AttributesLength2: PSQLSMALLINT): TSqlSmallInt{.
  749. dynlib: odbclib, importc.}
  750. proc SQLSetConnectAttr*(ConnectionHandle: SqlHDBC, Attribute: TSqlInteger,
  751. Value: SqlPointer, StringLength: TSqlInteger): TSqlSmallInt{.
  752. dynlib: odbclib, importc.}
  753. proc SQLGetCursorName*(StatementHandle: SqlHStmt, CursorName: PSQLCHAR,
  754. BufferLength: TSqlSmallInt, NameLength: PSQLSMALLINT): TSqlSmallInt{.
  755. dynlib: odbclib, importc.}
  756. proc SQLSetCursorName*(StatementHandle: SqlHStmt, CursorName: PSQLCHAR,
  757. NameLength: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib,
  758. importc.}
  759. proc SQLRowCount*(StatementHandle: SqlHStmt, RowCount: var TSQLLEN): TSqlSmallInt{.
  760. dynlib: odbclib, importc.}
  761. proc SQLBindParameter*(hstmt: SqlHStmt, ipar: SqlUSmallInt,
  762. fParamType: TSqlSmallInt, fCType: TSqlSmallInt,
  763. fSqlType: TSqlSmallInt, cbColDef: TSQLULEN,
  764. ibScale: TSqlSmallInt, rgbValue: SqlPointer,
  765. cbValueMax: TSQLLEN, pcbValue: var TSQLLEN): TSqlSmallInt{.
  766. dynlib: odbclib, importc.}
  767. proc SQLFreeStmt*(StatementHandle: SqlHStmt, Option: SqlUSmallInt): TSqlSmallInt{.
  768. dynlib: odbclib, importc.}
  769. proc SQLColAttribute*(StatementHandle: SqlHStmt, ColumnNumber: SqlUSmallInt,
  770. FieldIdentifier: SqlUSmallInt,
  771. CharacterAttribute: PSQLCHAR, BufferLength: TSqlSmallInt,
  772. StringLength: PSQLSMALLINT,
  773. NumericAttribute: TSQLLEN): TSqlSmallInt{.
  774. dynlib: odbclib, importc.}
  775. proc SQLEndTran*(HandleType: TSqlSmallInt, Handle: SqlHandle,
  776. CompletionType: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib,
  777. importc.}
  778. proc SQLTables*(hstmt: SqlHStmt, szTableQualifier: PSQLCHAR,
  779. cbTableQualifier: TSqlSmallInt, szTableOwner: PSQLCHAR,
  780. cbTableOwner: TSqlSmallInt, szTableName: PSQLCHAR,
  781. cbTableName: TSqlSmallInt, szTableType: PSQLCHAR,
  782. cbTableType: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib, importc.}
  783. proc SQLColumns*(hstmt: SqlHStmt, szTableQualifier: PSQLCHAR,
  784. cbTableQualifier: TSqlSmallInt, szTableOwner: PSQLCHAR,
  785. cbTableOwner: TSqlSmallInt, szTableName: PSQLCHAR,
  786. cbTableName: TSqlSmallInt, szColumnName: PSQLCHAR,
  787. cbColumnName: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib, importc.}
  788. proc SQLSpecialColumns*(StatementHandle: SqlHStmt, IdentifierType: SqlUSmallInt,
  789. CatalogName: PSQLCHAR, NameLength1: TSqlSmallInt,
  790. SchemaName: PSQLCHAR, NameLength2: TSqlSmallInt,
  791. TableName: PSQLCHAR, NameLength3: TSqlSmallInt,
  792. Scope: SqlUSmallInt,
  793. Nullable: SqlUSmallInt): TSqlSmallInt{.
  794. dynlib: odbclib, importc.}
  795. proc SQLProcedures*(hstmt: SqlHStmt, szTableQualifier: PSQLCHAR,
  796. cbTableQualifier: TSqlSmallInt, szTableOwner: PSQLCHAR,
  797. cbTableOwner: TSqlSmallInt, szTableName: PSQLCHAR,
  798. cbTableName: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib,
  799. importc.}
  800. proc SQLPrimaryKeys*(hstmt: SqlHStmt, CatalogName: PSQLCHAR,
  801. NameLength1: TSqlSmallInt, SchemaName: PSQLCHAR,
  802. NameLength2: TSqlSmallInt, TableName: PSQLCHAR,
  803. NameLength3: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib,
  804. importc.}
  805. proc SQLProcedureColumns*(hstmt: SqlHStmt, CatalogName: PSQLCHAR,
  806. NameLength1: TSqlSmallInt, SchemaName: PSQLCHAR,
  807. NameLength2: TSqlSmallInt, ProcName: PSQLCHAR,
  808. NameLength3: TSqlSmallInt, ColumnName: PSQLCHAR,
  809. NameLength4: TSqlSmallInt): TSqlSmallInt{.dynlib: odbclib,
  810. importc.}
  811. proc SQLStatistics*(hstmt: SqlHStmt, CatalogName: PSQLCHAR,
  812. NameLength1: TSqlSmallInt, SchemaName: PSQLCHAR,
  813. NameLength2: TSqlSmallInt, TableName: PSQLCHAR,
  814. NameLength3: TSqlSmallInt, Unique: SqlUSmallInt,
  815. Reserved: SqlUSmallInt): TSqlSmallInt {.
  816. dynlib: odbclib, importc.}
  817. proc SQLErr*(henv: SqlHEnv, hdbc: SqlHDBC, hstmt: SqlHStmt,
  818. szSqlState, pfNativeError, szErrorMsg: PSQLCHAR,
  819. cbErrorMsgMax: TSqlSmallInt,
  820. pcbErrorMsg: PSQLSMALLINT): TSqlSmallInt {.
  821. dynlib: odbclib, importc: "SQLError".}
  822. {.pop.}
  823. when defined(nimHasStyleChecks):
  824. {.pop.}