8#if __DCL_HAVE_ALLOC_DEBUG
9#undef __DCL_ALLOC_LEVEL
10#define __DCL_ALLOC_LEVEL __DCL_ALLOC_INTERNAL
22#ifndef SQLDA_CURRENT_VERSION
23 #define SQLDA_CURRENT_VERSION SQLDA_VERSION1
28#define __DCL_TRACE0_N __DCL_TRACE0
29#define __DCL_TRACE1_N __DCL_TRACE1
30#define __DCL_TRACE2_N __DCL_TRACE2
31#define __DCL_TRACE3_N __DCL_TRACE3
32#define __DCL_TRACE4_N __DCL_TRACE4
34#define __DCL_TRACE0_N(fmt)
35#define __DCL_TRACE1_N(fmt, arg)
36#define __DCL_TRACE2_N(fmt, arg1, arg2)
37#define __DCL_TRACE3_N(fmt, arg1, arg2, arg3)
38#define __DCL_TRACE4_N(fmt, arg1, arg2, arg3, arg4)
46#define __SET_ERROR(_error) \
47 conn()->setErrorHandle(_error, __THIS_FILE__, __LINE__)
48#define __SET_ERROR_MSG(_msg) \
49 conn()->setErrorMessage(_msg, __THIS_FILE__, __LINE__)
70 size_t buflen =
sizeof(buf) - 1;
71 bool b = conn()->__getErrorMessage(buf, &buflen);
72 buf[b ? buflen : 0] =
'\0';
88 Query::__affectedRows = -1;
97 Query::__fieldCount = 0;
105 Query::__paramCount = 0;
118 ISC_STATUS* statusVector = conn()->statusVector();
121 if (isc_dsql_free_statement(
134static size_t __TYPE_ALIGN(
size_t _offset,
int _sqltype)
137 switch(_sqltype & ~1) {
142 size =
sizeof(short);
148 size =
sizeof(ISC_INT64);
151 size =
sizeof(float);
154 size =
sizeof(double);
157 size =
sizeof(ISC_DATE);
160 size =
sizeof(ISC_TIME);
163 size =
sizeof(ISC_TIMESTAMP);
165#if defined(FIREBIRD_IBASE_H) && FB_API_VER >= 40
167 size =
sizeof(ISC_TIME_TZ_EX);
169 case SQL_TIMESTAMP_TZ_EX:
170 size =
sizeof(ISC_TIMESTAMP_TZ_EX);
177 size =
sizeof(short);
180 size =
sizeof(ISC_QUAD);
184 _offset, _sqltype, _sqltype & ~1);
189 return (_offset + size - 1) & ~(size - 1);
195 && (Query::__fieldCount == 0)
200 ISC_STATUS* statusVector = conn()->statusVector();
201 __outSQLDA = (XSQLDA*)malloc(XSQLDA_LENGTH(1));
209 if(isc_dsql_describe(
233 if (isc_dsql_describe(
247 for(
short i = 0; i <
__outSQLDA->sqld; i++, sqlvar++) {
248 offset = __TYPE_ALIGN(offset, sqlvar->sqltype);
249 switch(sqlvar->sqltype & ~1) {
251 offset += sqlvar->sqllen + 1;
254 offset += sqlvar->sqllen +
sizeof(short) + 1;
257 offset += sqlvar->sqllen;
275 for(
short i = 0; i <
__outSQLDA->sqld; i++, sqlvar++) {
276 offset = __TYPE_ALIGN(offset, sqlvar->sqltype);
277 sqlvar->sqldata = outBuffer + offset;
278 switch(sqlvar->sqltype & ~1) {
280 offset += sqlvar->sqllen + 1;
283 offset += sqlvar->sqllen +
sizeof(short) + 1;
286 offset += sqlvar->sqllen;
298 for (
size_t i = 0; i < Query::__fieldCount; i++, sqlvar++) {
299 if (!
__fields[i].init(
this, sqlvar))
309 && (Query::__paramCount == 0)
314 short paramCount = (short)_paramCount;
315 ISC_STATUS* statusVector = conn()->statusVector();
316 __inSQLDA = (XSQLDA*)malloc(XSQLDA_LENGTH(paramCount));
324 if (isc_dsql_describe_bind(
343 for(
size_t i = 0; i < Query::__paramCount; i++, sqlvar++) {
344 if (!
__params[i].init(
this, sqlvar)) {
352static char stmt_info_item[] = { isc_info_sql_stmt_type };
353static char count_info_item[] = { isc_info_sql_records };
361 if (isc_dsql_allocate_statement(
362 conn()->statusVector(),
363 conn()->dbHandlePtr(),
370#ifdef FIREBIRD_IBASE_H
375 ISC_STATUS rs = isc_dsql_prepare(
376 conn()->statusVector(),
377 conn()->trHandlePtr(),
390 if (isc_dsql_sql_info(
391 conn()->statusVector(),
393 sizeof(stmt_info_item),
402 if (res_buffer[0] != isc_info_sql_stmt_type) {
407 int len = isc_vax_integer(&res_buffer[1], 2);
408 __stmtType = isc_vax_integer(&res_buffer[3], len);
412 || (
__stmtType == isc_info_sql_stmt_select_for_upd)
413 || (
__stmtType == isc_info_sql_stmt_exec_procedure)
419 if (_paramCount > 0) {
430 if (
__stmtType == isc_info_sql_stmt_exec_procedure) {
434 if (isc_dsql_execute2(
435 conn()->statusVector(),
436 conn()->trHandlePtr(),
447 if (isc_dsql_execute(
448 conn()->statusVector(),
449 conn()->trHandlePtr(),
459 for (
size_t i = 0; i < Query::__paramCount; i++) {
466 unsigned char count_type = 0;
468 case isc_info_sql_stmt_update: {
469 count_type = isc_info_req_update_count;
472 case isc_info_sql_stmt_delete: {
473 count_type = isc_info_req_delete_count;
476 case isc_info_sql_stmt_insert: {
477 count_type = isc_info_req_insert_count;
480 case isc_info_sql_stmt_select:
481 case isc_info_sql_stmt_select_for_upd: {
482 Query::__eof =
false;
485 case isc_info_sql_stmt_exec_procedure: {
486 Query::__eof =
false;
487 for (
size_t i = 0; i < Query::__fieldCount; i++) {
496 unsigned char count_is = 0;
497 char count_buffer[33];
498 unsigned short length;
500 if (isc_dsql_sql_info(
501 conn()->statusVector(),
503 sizeof(count_info_item),
505 sizeof(count_buffer),
512 for(
char* p = count_buffer + 3; *p != isc_info_end; ) {
514 length = (
unsigned short)isc_vax_integer(p, 2);
516 Query::__affectedRows = isc_vax_integer(p, length);
518 if (count_is == count_type)
529 if (
__stmtType == isc_info_sql_stmt_exec_procedure) {
542 ||
__stmtType == isc_info_sql_stmt_select_for_upd);
543 ISC_STATUS rs = isc_dsql_fetch(
544 conn()->statusVector(),
550 for(
size_t i = 0; i < Query::__fieldCount; i++) {
556 else if (rs == 100) {
569 __DCL_ASSERT((0 <= _index) && (_index < Query::__fieldCount));
570 *_fieldHandleOut = &
__fields[_index];
577 __DCL_ASSERT((0 <= _index) && (_index < Query::__paramCount));
578 *_paramHandleOut = &
__params[_index];
#define __DCL_TRACE1_N(fmt, arg)
#define __DCL_TRACE2_N(fmt, arg1, arg2)
#define SQLDA_CURRENT_VERSION
#define __DCL_TRACE3_N(fmt, arg1, arg2, arg3)
#define _IB_STMT_TYPE_UNKNOWN
#define __DCL_TRACE1(fmt, arg1)
#define __DCL_ASSERT(expr)
#define IMPLEMENT_CLASSINFO(class_name, base_class_name)
#define __SET_ERROR(_errorCode)
IBQuery(IBConnection *_connHandle)
bool initParams(size_t _paramCount)
virtual bool __getField(size_t _index, SQL::Field **_fieldHandleOut)
virtual bool __prepare(const char *_sql, size_t _sqllen, size_t _paramCount)
virtual bool __getParam(size_t _index, SQL::Param **_paramHandleOut)
isc_stmt_handle __stmtHandle