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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 /* ONLY USED FOR ODBC Version 2 -DODBCV2
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)
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
34 #define SQL_SUCCEEDED(rc) (((rc)&(~1))==0)
38 #define SQLSetEnvAttr(henv, Attribute, Value, StringLength) (0)
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) \
48 #define SQLFreeHandle(type, hndl) \
49 ( (type == SQL_HANDLE_STMT) ? SQLFreeStmt(hndl, SQL_DROP) \
50 : (type == SQL_HANDLE_ENV) ? SQLFreeEnv(hndl) \
51 : SQLFreeConnect(hndl) \
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)
62 #define SQLCloseCursor(stmt) SQLFreeStmt(stmt, SQL_CLOSE)
64 #undef SQLGetConnectAttr
65 #define SQLGetConnectAttr(hdbc, fOption, ValuePtr, BufferLength, NULL) \
66 SQLGetConnectOption(hdbc, fOption, ValuePtr)
68 #undef SQLSetConnectAttr
69 #define SQLSetConnectAttr(hdbc, fOption, ValuePtr, BufferLength) \
70 SQLSetConnectOption(hdbc, fOption, (SQLUINTEGER) ValuePtr)
73 #define SQLSetStmtAttr(hstmt, fOption, ValuePtr, BufferLength) (0); return APR_ENOTIMPL;
76 #define SQLEndTran(hType, hdbc,type) SQLTransact(henv, hdbc, type)
79 #define SQLFetchScroll(stmt, orient, rownum) (0); return APR_ENOTIMPL;
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
87 #undef SQLColAttribute
88 #define SQLColAttribute(s, c, f, a, l, m, n) SQLColAttributes(s, c, f, a, l, m, n)
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
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 */
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
112 #define SQL_ATTR_CURSOR_SCROLLABLE -1
114 #define SQL_C_SBIGINT (SQL_BIGINT+SQL_SIGNED_OFFSET) /* SIGNED BIGINT */
115 #define SQL_C_UBIGINT (SQL_BIGINT+SQL_UNSIGNED_OFFSET) /* UNSIGNED BIGINT */