File: sql.h

package info (click to toggle)
libiodbc2 2.50.3-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 860 kB
  • ctags: 1,245
  • sloc: ansic: 8,060; sh: 6,664; makefile: 81
file content (326 lines) | stat: -rw-r--r-- 6,894 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
/*
 *  sql.h
 *
 *  $Id: sql.h,v 1.1 1999/06/25 03:02:44 source Exp $
 *
 *  ODBC defines
 *
 *  The iODBC driver manager.
 *  
 *  Copyright (C) 1995 by Ke Jin <kejin@empress.com> 
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Library General Public
 *  License as published by the Free Software Foundation; either
 *  version 2 of the License, or (at your option) any later version.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Library General Public License for more details.
 *
 *  You should have received a copy of the GNU Library General Public
 *  License along with this library; if not, write to the Free
 *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
#ifndef _SQL_H
#define _SQL_H

/*
 *  Set default specification to ODBC 2.50
 */
#ifndef ODBCVER
#define ODBCVER				0x0250
#endif

#ifndef _SQLTYPES_H
#include <sqltypes.h>
#endif

#ifdef __cplusplus
extern "C" {
#endif

/*
 *  Useful Constants
 */
#define SQL_SPEC_MAJOR			2
#define SQL_SPEC_MINOR			50
#define SQL_SPEC_STRING			"02.50"

#define SQL_SQLSTATE_SIZE		5
#define SQL_MAX_MESSAGE_LENGTH		512
#define SQL_MAX_DSN_LENGTH		32
#define SQL_MAX_OPTION_STRING_LENGTH	256

/*
 *  Handle types
 */
#define SQL_HANDLE_ENV			1
#define SQL_HANDLE_DBC			2
#define SQL_HANDLE_STMT			3
#if (ODBCVER >= 0x0300)
#define SQL_HANDLE_DESC			4
#endif

/*
 *  Function return codes
 */
#define SQL_INVALID_HANDLE		(-2)
#define SQL_ERROR			(-1)
#define SQL_SUCCESS 			0
#define SQL_SUCCESS_WITH_INFO		1
#define SQL_NO_DATA_FOUND		100


/*
 *  Standard SQL datatypes, using ANSI type numbering
 */
#define SQL_UNKNOWN_TYPE		0
#define SQL_CHAR			1
#define SQL_NUMERIC 			2
#define SQL_DECIMAL 			3
#define SQL_INTEGER 			4
#define SQL_SMALLINT			5
#define SQL_FLOAT			6
#define SQL_REAL			7
#define SQL_DOUBLE			8
#define SQL_VARCHAR 			12

#define SQL_TYPE_NULL			0
#define SQL_TYPE_MIN			SQL_CHAR
#define SQL_TYPE_MAX			SQL_VARCHAR


/*
 *  C datatype to SQL datatype mapping
 */
#define SQL_C_CHAR			SQL_CHAR
#define SQL_C_LONG			SQL_INTEGER
#define SQL_C_SHORT			SQL_SMALLINT
#define SQL_C_FLOAT			SQL_REAL
#define SQL_C_DOUBLE			SQL_DOUBLE
#define SQL_C_DEFAULT 			99


/*
 *  NULL status constants.
 */
#define SQL_NO_NULLS			0
#define SQL_NULLABLE			1
#define SQL_NULLABLE_UNKNOWN		2


/*
 *  Special length values
 */
#define SQL_NULL_DATA			(-1)
#define SQL_DATA_AT_EXEC		(-2)
#define SQL_NTS 			(-3)


/*
 *  SQLFreeStmt
 */
#define SQL_CLOSE			0
#define SQL_DROP			1
#define SQL_UNBIND			2
#define SQL_RESET_PARAMS		3


/*
 *  SQLTransact
 */
#define SQL_COMMIT			0
#define SQL_ROLLBACK			1


/*
 *  SQLColAttributes
 */
#define SQL_COLUMN_COUNT		0
#define SQL_COLUMN_NAME			1
#define SQL_COLUMN_TYPE			2
#define SQL_COLUMN_LENGTH		3
#define SQL_COLUMN_PRECISION		4
#define SQL_COLUMN_SCALE		5
#define SQL_COLUMN_DISPLAY_SIZE		6
#define SQL_COLUMN_NULLABLE		7
#define SQL_COLUMN_UNSIGNED		8
#define SQL_COLUMN_MONEY		9
#define SQL_COLUMN_UPDATABLE		10
#define SQL_COLUMN_AUTO_INCREMENT	11
#define SQL_COLUMN_CASE_SENSITIVE	12
#define SQL_COLUMN_SEARCHABLE		13
#define SQL_COLUMN_TYPE_NAME		14
#define SQL_COLUMN_TABLE_NAME		15
#define SQL_COLUMN_OWNER_NAME		16
#define SQL_COLUMN_QUALIFIER_NAME	17
#define SQL_COLUMN_LABEL		18

#define SQL_COLATT_OPT_MAX		SQL_COLUMN_LABEL
#define	SQL_COLATT_OPT_MIN		SQL_COLUMN_COUNT
#define SQL_COLUMN_DRIVER_START		1000


/*
 *  SQLColAttributes : SQL_COLUMN_UPDATABLE
 */
#define SQL_ATTR_READONLY		0
#define SQL_ATTR_WRITE			1
#define SQL_ATTR_READWRITE_UNKNOWN	2


/*
 *  SQLColAttributes : SQL_COLUMN_SEARCHABLE
 */
#define SQL_UNSEARCHABLE		0
#define SQL_LIKE_ONLY			1
#define SQL_ALL_EXCEPT_LIKE 		2
#define SQL_SEARCHABLE			3


/*
 *  NULL Handles
 */
#define SQL_NULL_HENV			0
#define SQL_NULL_HDBC			0
#define SQL_NULL_HSTMT			0


/*
 *  Function Prototypes
 */

SQLRETURN SQL_API SQLAllocConnect (
    SQLHENV henv,
    SQLHDBC FAR * phdbc);

SQLRETURN SQL_API SQLAllocEnv (
    SQLHENV FAR * phenv);

SQLRETURN SQL_API SQLAllocStmt (
    SQLHDBC hdbc,
    SQLHSTMT FAR * phstmt);

SQLRETURN SQL_API SQLBindCol (
    SQLHSTMT hstmt,
    SQLUSMALLINT icol,
    SQLSMALLINT fCType,
    SQLPOINTER rgbValue,
    SQLINTEGER cbValueMax,
    SQLINTEGER FAR * pcbValue);

SQLRETURN SQL_API SQLCancel (
    SQLHSTMT hstmt);

SQLRETURN SQL_API SQLColAttributes (
    SQLHSTMT hstmt,
    SQLUSMALLINT icol,
    SQLUSMALLINT fDescType,
    SQLPOINTER rgbDesc,
    SQLSMALLINT cbDescMax,
    SQLSMALLINT FAR * pcbDesc,
    SQLINTEGER FAR * pfDesc);

SQLRETURN SQL_API SQLConnect (
    SQLHDBC hdbc,
    SQLCHAR FAR * szDSN,
    SQLSMALLINT cbDSN,
    SQLCHAR FAR * szUID,
    SQLSMALLINT cbUID,
    SQLCHAR FAR * szAuthStr,
    SQLSMALLINT cbAuthStr);

SQLRETURN SQL_API SQLDescribeCol (
    SQLHSTMT hstmt,
    SQLUSMALLINT icol,
    SQLCHAR FAR * szColName,
    SQLSMALLINT cbColNameMax,
    SQLSMALLINT FAR * pcbColName,
    SQLSMALLINT FAR * pfSqlType,
    SQLUINTEGER FAR * pcbColDef,
    SQLSMALLINT FAR * pibScale,
    SQLSMALLINT FAR * pfNullable);

SQLRETURN SQL_API SQLDisconnect (
    SQLHDBC hdbc);

SQLRETURN SQL_API SQLError (
    SQLHENV henv,
    SQLHDBC hdbc,
    SQLHSTMT hstmt,
    SQLCHAR FAR * szSqlState,
    SQLINTEGER FAR * pfNativeError,
    SQLCHAR FAR * szErrorMsg,
    SQLSMALLINT cbErrorMsgMax,
    SQLSMALLINT FAR * pcbErrorMsg);

SQLRETURN SQL_API SQLExecDirect (
    SQLHSTMT hstmt,
    SQLCHAR FAR * szSqlStr,
    SQLINTEGER cbSqlStr);

SQLRETURN SQL_API SQLExecute (
    SQLHSTMT hstmt);

SQLRETURN SQL_API SQLFetch (
    SQLHSTMT hstmt);

SQLRETURN SQL_API SQLFreeConnect (
    SQLHDBC hdbc);

SQLRETURN SQL_API SQLFreeEnv (
    SQLHENV henv);

SQLRETURN SQL_API SQLFreeStmt (
    SQLHSTMT hstmt,
    SQLUSMALLINT fOption);

SQLRETURN SQL_API SQLGetCursorName (
    SQLHSTMT hstmt,
    SQLCHAR FAR * szCursor,
    SQLSMALLINT cbCursorMax,
    SQLSMALLINT FAR * pcbCursor);

SQLRETURN SQL_API SQLNumResultCols (
    SQLHSTMT hstmt,
    SQLSMALLINT FAR * pccol);

SQLRETURN SQL_API SQLPrepare (
    SQLHSTMT hstmt,
    SQLCHAR FAR * szSqlStr,
    SQLINTEGER cbSqlStr);

SQLRETURN SQL_API SQLRowCount (
    SQLHSTMT hstmt,
    SQLINTEGER FAR * pcrow);

SQLRETURN SQL_API SQLSetCursorName (
    SQLHSTMT hstmt,
    SQLCHAR FAR * szCursor,
    SQLSMALLINT cbCursor);

SQLRETURN SQL_API SQLTransact (
    SQLHENV henv,
    SQLHDBC hdbc,
    SQLUSMALLINT fType);

/*
 *  Depreciated ODBC 1.0 function - Use SQLBindParameter
 */
SQLRETURN SQL_API SQLSetParam (
    SQLHSTMT hstmt,
    SQLUSMALLINT ipar,
    SQLSMALLINT fCType,
    SQLSMALLINT fSqlType,
    SQLUINTEGER cbParamDef,
    SQLSMALLINT ibScale,
    SQLPOINTER rgbValue,
    SQLINTEGER FAR * pcbValue);

#ifdef __cplusplus
}
#endif

#endif /* _SQL_H */