Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

320 lines
8.3 KiB

  1. /*****************************************************************
  2. ** SQL.H - This is the the main include for ODBC Core functions.
  3. **
  4. ** preconditions:
  5. ** #include "windows.h"
  6. **
  7. ** (C) Copyright 1990 - 1994 By Microsoft Corp.
  8. **
  9. ** Updated 5/12/93 for 2.00 specification
  10. ** Updated 5/23/94 for 2.01 specification
  11. *********************************************************************/
  12. #ifndef __SQL
  13. #define __SQL
  14. /*
  15. * ODBCVER ODBC version number (0x0200). To exclude
  16. * definitions introduced in version 2.0 (or above)
  17. * #define ODBCVER 0x0100 before #including <sql.h>
  18. */
  19. /* If ODBCVER is not defined, assume version 2.01 */
  20. #ifndef ODBCVER
  21. #define ODBCVER 0x0201
  22. #endif
  23. #ifdef __cplusplus
  24. extern "C" { /* Assume C declarations for C++ */
  25. #endif /* __cplusplus */
  26. /* generally useful constants */
  27. #if (ODBCVER >= 0x0200)
  28. #define SQL_SPEC_MAJOR 2 /* Major version of specification */
  29. #define SQL_SPEC_MINOR 1 /* Minor version of specification */
  30. #define SQL_SPEC_STRING "02.01" /* String constant for version */
  31. #endif /* ODBCVER >= 0x0200 */
  32. #define SQL_SQLSTATE_SIZE 5 /* size of SQLSTATE */
  33. #define SQL_MAX_MESSAGE_LENGTH 512 /* message buffer size */
  34. #define SQL_MAX_DSN_LENGTH 32 /* maximum data source name size */
  35. /* RETCODEs */
  36. #define SQL_INVALID_HANDLE (-2)
  37. #define SQL_ERROR (-1)
  38. #define SQL_SUCCESS 0
  39. #define SQL_SUCCESS_WITH_INFO 1
  40. #define SQL_NO_DATA_FOUND 100
  41. /* Standard SQL datatypes, using ANSI type numbering */
  42. #define SQL_CHAR 1
  43. #define SQL_NUMERIC 2
  44. #define SQL_DECIMAL 3
  45. #define SQL_INTEGER 4
  46. #define SQL_SMALLINT 5
  47. #define SQL_FLOAT 6
  48. #define SQL_REAL 7
  49. #define SQL_DOUBLE 8
  50. #define SQL_VARCHAR 12
  51. #define SQL_TYPE_MIN SQL_CHAR
  52. #define SQL_TYPE_NULL 0
  53. #define SQL_TYPE_MAX SQL_VARCHAR
  54. /* C datatype to SQL datatype mapping SQL types
  55. ------------------- */
  56. #define SQL_C_CHAR SQL_CHAR /* CHAR, VARCHAR, DECIMAL, NUMERIC */
  57. #define SQL_C_LONG SQL_INTEGER /* INTEGER */
  58. #define SQL_C_SHORT SQL_SMALLINT /* SMALLINT */
  59. #define SQL_C_FLOAT SQL_REAL /* REAL */
  60. #define SQL_C_DOUBLE SQL_DOUBLE /* FLOAT, DOUBLE */
  61. #define SQL_C_DEFAULT 99
  62. /* NULL status constants. These are used in SQLColumns, SQLColAttributes,
  63. SQLDescribeCol, SQLDescribeParam, and SQLSpecialColumns to describe the
  64. nullablity of a column in a table. */
  65. #define SQL_NO_NULLS 0
  66. #define SQL_NULLABLE 1
  67. #define SQL_NULLABLE_UNKNOWN 2
  68. /* Special length values */
  69. #define SQL_NULL_DATA (-1)
  70. #define SQL_DATA_AT_EXEC (-2)
  71. #define SQL_NTS (-3)
  72. /* SQLFreeStmt defines */
  73. #define SQL_CLOSE 0
  74. #define SQL_DROP 1
  75. #define SQL_UNBIND 2
  76. #define SQL_RESET_PARAMS 3
  77. /* SQLTransact defines */
  78. #define SQL_COMMIT 0
  79. #define SQL_ROLLBACK 1
  80. /* SQLColAttributes defines */
  81. #define SQL_COLUMN_COUNT 0
  82. #define SQL_COLUMN_NAME 1
  83. #define SQL_COLUMN_TYPE 2
  84. #define SQL_COLUMN_LENGTH 3
  85. #define SQL_COLUMN_PRECISION 4
  86. #define SQL_COLUMN_SCALE 5
  87. #define SQL_COLUMN_DISPLAY_SIZE 6
  88. #define SQL_COLUMN_NULLABLE 7
  89. #define SQL_COLUMN_UNSIGNED 8
  90. #define SQL_COLUMN_MONEY 9
  91. #define SQL_COLUMN_UPDATABLE 10
  92. #define SQL_COLUMN_AUTO_INCREMENT 11
  93. #define SQL_COLUMN_CASE_SENSITIVE 12
  94. #define SQL_COLUMN_SEARCHABLE 13
  95. #define SQL_COLUMN_TYPE_NAME 14
  96. #if (ODBCVER >= 0x0200)
  97. #define SQL_COLUMN_TABLE_NAME 15
  98. #define SQL_COLUMN_OWNER_NAME 16
  99. #define SQL_COLUMN_QUALIFIER_NAME 17
  100. #define SQL_COLUMN_LABEL 18
  101. #define SQL_COLATT_OPT_MAX SQL_COLUMN_LABEL
  102. #else
  103. #define SQL_COLATT_OPT_MAX SQL_COLUMN_TYPE_NAME
  104. #endif /* ODBCVER >= 0x0200 */
  105. #define SQL_COLUMN_DRIVER_START 1000
  106. #define SQL_COLATT_OPT_MIN SQL_COLUMN_COUNT
  107. /* SQLColAttributes subdefines for SQL_COLUMN_UPDATABLE */
  108. #define SQL_ATTR_READONLY 0
  109. #define SQL_ATTR_WRITE 1
  110. #define SQL_ATTR_READWRITE_UNKNOWN 2
  111. /* SQLColAttributes subdefines for SQL_COLUMN_SEARCHABLE */
  112. /* These are also used by SQLGetInfo */
  113. #define SQL_UNSEARCHABLE 0
  114. #define SQL_LIKE_ONLY 1
  115. #define SQL_ALL_EXCEPT_LIKE 2
  116. #define SQL_SEARCHABLE 3
  117. /* SQLError defines */
  118. #define SQL_NULL_HENV 0
  119. #define SQL_NULL_HDBC 0
  120. #define SQL_NULL_HSTMT 0
  121. /* environment specific definitions */
  122. #ifndef EXPORT
  123. #define EXPORT _export
  124. #endif
  125. #ifdef WIN32
  126. #define SQL_API __stdcall
  127. #else
  128. #define SQL_API EXPORT CALLBACK
  129. #endif
  130. #ifndef RC_INVOKED
  131. /* SQL portable types for C */
  132. typedef unsigned char UCHAR;
  133. typedef signed char SCHAR;
  134. typedef long int SDWORD;
  135. typedef short int SWORD;
  136. typedef unsigned long int UDWORD;
  137. typedef unsigned short int UWORD;
  138. #if (ODBCVER >= 0x0200)
  139. typedef signed long SLONG;
  140. typedef signed short SSHORT;
  141. typedef unsigned long ULONG;
  142. typedef unsigned short USHORT;
  143. #endif /* ODBCVER >= 0x0200 */
  144. typedef double SDOUBLE;
  145. #ifdef WIN32
  146. typedef double LDOUBLE; /* long double == short double in Win32 */
  147. #else
  148. typedef long double LDOUBLE;
  149. #endif
  150. typedef float SFLOAT;
  151. typedef void FAR * PTR;
  152. typedef void FAR * HENV;
  153. typedef void FAR * HDBC;
  154. typedef void FAR * HSTMT;
  155. typedef signed short RETCODE;
  156. /* Core Function Prototypes */
  157. RETCODE SQL_API SQLAllocConnect(
  158. HENV henv,
  159. HDBC FAR *phdbc);
  160. RETCODE SQL_API SQLAllocEnv(
  161. HENV FAR *phenv);
  162. RETCODE SQL_API SQLAllocStmt(
  163. HDBC hdbc,
  164. HSTMT FAR *phstmt);
  165. RETCODE SQL_API SQLBindCol(
  166. HSTMT hstmt,
  167. UWORD icol,
  168. SWORD fCType,
  169. PTR rgbValue,
  170. SDWORD cbValueMax,
  171. SDWORD FAR *pcbValue);
  172. RETCODE SQL_API SQLCancel(
  173. HSTMT hstmt);
  174. RETCODE SQL_API SQLColAttributes(
  175. HSTMT hstmt,
  176. UWORD icol,
  177. UWORD fDescType,
  178. PTR rgbDesc,
  179. SWORD cbDescMax,
  180. SWORD FAR *pcbDesc,
  181. SDWORD FAR *pfDesc);
  182. RETCODE SQL_API SQLConnect(
  183. HDBC hdbc,
  184. UCHAR FAR *szDSN,
  185. SWORD cbDSN,
  186. UCHAR FAR *szUID,
  187. SWORD cbUID,
  188. UCHAR FAR *szAuthStr,
  189. SWORD cbAuthStr);
  190. RETCODE SQL_API SQLDescribeCol(
  191. HSTMT hstmt,
  192. UWORD icol,
  193. UCHAR FAR *szColName,
  194. SWORD cbColNameMax,
  195. SWORD FAR *pcbColName,
  196. SWORD FAR *pfSqlType,
  197. UDWORD FAR *pcbColDef,
  198. SWORD FAR *pibScale,
  199. SWORD FAR *pfNullable);
  200. RETCODE SQL_API SQLDisconnect(
  201. HDBC hdbc);
  202. RETCODE SQL_API SQLError(
  203. HENV henv,
  204. HDBC hdbc,
  205. HSTMT hstmt,
  206. UCHAR FAR *szSqlState,
  207. SDWORD FAR *pfNativeError,
  208. UCHAR FAR *szErrorMsg,
  209. SWORD cbErrorMsgMax,
  210. SWORD FAR *pcbErrorMsg);
  211. RETCODE SQL_API SQLExecDirect(
  212. HSTMT hstmt,
  213. UCHAR FAR *szSqlStr,
  214. SDWORD cbSqlStr);
  215. RETCODE SQL_API SQLExecute(
  216. HSTMT hstmt);
  217. RETCODE SQL_API SQLFetch(
  218. HSTMT hstmt);
  219. RETCODE SQL_API SQLFreeConnect(
  220. HDBC hdbc);
  221. RETCODE SQL_API SQLFreeEnv(
  222. HENV henv);
  223. RETCODE SQL_API SQLFreeStmt(
  224. HSTMT hstmt,
  225. UWORD fOption);
  226. RETCODE SQL_API SQLGetCursorName(
  227. HSTMT hstmt,
  228. UCHAR FAR *szCursor,
  229. SWORD cbCursorMax,
  230. SWORD FAR *pcbCursor);
  231. RETCODE SQL_API SQLNumResultCols(
  232. HSTMT hstmt,
  233. SWORD FAR *pccol);
  234. RETCODE SQL_API SQLPrepare(
  235. HSTMT hstmt,
  236. UCHAR FAR *szSqlStr,
  237. SDWORD cbSqlStr);
  238. RETCODE SQL_API SQLRowCount(
  239. HSTMT hstmt,
  240. SDWORD FAR *pcrow);
  241. RETCODE SQL_API SQLSetCursorName(
  242. HSTMT hstmt,
  243. UCHAR FAR *szCursor,
  244. SWORD cbCursor);
  245. RETCODE SQL_API SQLTransact(
  246. HENV henv,
  247. HDBC hdbc,
  248. UWORD fType);
  249. #endif /* RC_INVOKED */
  250. /* Deprecrated functions from prior versions of ODBC */
  251. #ifndef RC_INVOKED
  252. RETCODE SQL_API SQLSetParam( /* Use SQLBindParameter */
  253. HSTMT hstmt,
  254. UWORD ipar,
  255. SWORD fCType,
  256. SWORD fSqlType,
  257. UDWORD cbColDef,
  258. SWORD ibScale,
  259. PTR rgbValue,
  260. SDWORD FAR *pcbValue);
  261. #endif /* RC_INVOKED */
  262. #ifdef __cplusplus
  263. } /* End of extern "C" { */
  264. #endif /* __cplusplus */
  265. #endif /* #ifndef __SQL */