Apache2
apr_dbd_odbc_v2.h
Go to the documentation of this file.
1 /* Licensed to the Apache Software Foundation (ASF) under one or more
2  * contributor license agreements. See the NOTICE file distributed with
3  * this work for additional information regarding copyright ownership.
4  * The ASF licenses this file to You under the Apache License, Version 2.0
5  * (the "License"); you may not use this file except in compliance with
6  * the License. You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 
18 /* ONLY USED FOR ODBC Version 2 -DODBCV2
19 *
20 * Re-define everything to work (more-or-less) in an ODBC V2 environment
21 * Random access to retrieved rows is not supported - i.e. calls to apr_dbd_select() cannot
22 * have a 'random' argument of 1. apr_dbd_get_row() must always pass rownum as 0 (get next row)
23 *
24 */
25 
26 #define SQLHANDLE SQLHENV /* Presumes that ENV, DBC, and STMT handles are all the same datatype */
27 #define SQL_NULL_HANDLE 0
28 #define SQL_HANDLE_STMT 1
29 #define SQL_HANDLE_DBC 2
30 #define SQL_HANDLE_ENV 3
31 #define SQL_NO_DATA SQL_NO_DATA_FOUND
32 
33 #ifndef SQL_SUCCEEDED
34 #define SQL_SUCCEEDED(rc) (((rc)&(~1))==0)
35 #endif
36 
37 #undef SQLSetEnvAttr
38 #define SQLSetEnvAttr(henv, Attribute, Value, StringLength) (0)
39 
40 #undef SQLAllocHandle
41 #define SQLAllocHandle(type, parent, hndl) \
42 ( (type == SQL_HANDLE_STMT) ? SQLAllocStmt(parent, hndl) \
43  : (type == SQL_HANDLE_ENV) ? SQLAllocEnv(hndl) \
44  : SQLAllocConnect(parent, hndl) \
45 )
46 
47 #undef SQLFreeHandle
48 #define SQLFreeHandle(type, hndl) \
49 ( (type == SQL_HANDLE_STMT) ? SQLFreeStmt(hndl, SQL_DROP) \
50  : (type == SQL_HANDLE_ENV) ? SQLFreeEnv(hndl) \
51  : SQLFreeConnect(hndl) \
52 )
53 
54 #undef SQLGetDiagRec
55 #define SQLGetDiagRec(type, h, i, state, native, buffer, bufsize, reslen) \
56  SQLError( (type == SQL_HANDLE_ENV) ? h : NULL, \
57  (type == SQL_HANDLE_DBC) ? h : NULL, \
58  (type == SQL_HANDLE_STMT) ? h : NULL, \
59  state, native, buffer, bufsize, reslen)
60 
61 #undef SQLCloseCursor
62 #define SQLCloseCursor(stmt) SQLFreeStmt(stmt, SQL_CLOSE)
63 
64 #undef SQLGetConnectAttr
65 #define SQLGetConnectAttr(hdbc, fOption, ValuePtr, BufferLength, NULL) \
66  SQLGetConnectOption(hdbc, fOption, ValuePtr)
67 
68 #undef SQLSetConnectAttr
69 #define SQLSetConnectAttr(hdbc, fOption, ValuePtr, BufferLength) \
70  SQLSetConnectOption(hdbc, fOption, (SQLUINTEGER) ValuePtr)
71 
72 #undef SQLSetStmtAttr
73 #define SQLSetStmtAttr(hstmt, fOption, ValuePtr, BufferLength) (0); return APR_ENOTIMPL;
74 
75 #undef SQLEndTran
76 #define SQLEndTran(hType, hdbc,type) SQLTransact(henv, hdbc, type)
77 
78 #undef SQLFetchScroll
79 #define SQLFetchScroll(stmt, orient, rownum) (0); return APR_ENOTIMPL;
80 
81 #define SQL_DESC_TYPE SQL_COLUMN_TYPE
82 #define SQL_DESC_CONCISE_TYPE SQL_COLUMN_TYPE
83 #define SQL_DESC_DISPLAY_SIZE SQL_COLUMN_DISPLAY_SIZE
84 #define SQL_DESC_OCTET_LENGTH SQL_COLUMN_LENGTH
85 #define SQL_DESC_UNSIGNED SQL_COLUMN_UNSIGNED
86 
87 #undef SQLColAttribute
88 #define SQLColAttribute(s, c, f, a, l, m, n) SQLColAttributes(s, c, f, a, l, m, n)
89 
90 #define SQL_ATTR_ACCESS_MODE SQL_ACCESS_MODE
91 #define SQL_ATTR_AUTOCOMMIT SQL_AUTOCOMMIT
92 #define SQL_ATTR_CONNECTION_TIMEOUT 113
93 #define SQL_ATTR_CURRENT_CATALOG SQL_CURRENT_QUALIFIER
94 #define SQL_ATTR_DISCONNECT_BEHAVIOR 114
95 #define SQL_ATTR_ENLIST_IN_DTC 1207
96 #define SQL_ATTR_ENLIST_IN_XA 1208
97 
98 #define SQL_ATTR_CONNECTION_DEAD 1209
99 #define SQL_CD_TRUE 1L /* Connection is closed/dead */
100 #define SQL_CD_FALSE 0L /* Connection is open/available */
101 
102 #define SQL_ATTR_LOGIN_TIMEOUT SQL_LOGIN_TIMEOUT
103 #define SQL_ATTR_ODBC_CURSORS SQL_ODBC_CURSORS
104 #define SQL_ATTR_PACKET_SIZE SQL_PACKET_SIZE
105 #define SQL_ATTR_QUIET_MODE SQL_QUIET_MODE
106 #define SQL_ATTR_TRACE SQL_OPT_TRACE
107 #define SQL_ATTR_TRACEFILE SQL_OPT_TRACEFILE
108 #define SQL_ATTR_TRANSLATE_LIB SQL_TRANSLATE_DLL
109 #define SQL_ATTR_TRANSLATE_OPTION SQL_TRANSLATE_OPTION
110 #define SQL_ATTR_TXN_ISOLATION SQL_TXN_ISOLATION
111 
112 #define SQL_ATTR_CURSOR_SCROLLABLE -1
113 
114 #define SQL_C_SBIGINT (SQL_BIGINT+SQL_SIGNED_OFFSET) /* SIGNED BIGINT */
115 #define SQL_C_UBIGINT (SQL_BIGINT+SQL_UNSIGNED_OFFSET) /* UNSIGNED BIGINT */
116 
117 #define SQL_FALSE 0
118 #define SQL_TRUE 1
119