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
52 ByteBuffer*
buf = ByteBuffer::create(
n);
53 bool b = conn()->__getErrorMessage(
buf->data(), &
n);
55 buf->__dataLength =
n;
80 Query::__affectedRows = -1;
89 Query::__fieldCount = 0;
97 Query::__paramCount = 0;
115 ISC_STATUS* statusVector = conn()->statusVector();
118 if (isc_dsql_free_statement(
132static size_t __TYPE_ALIGN(
size_t _offset,
int _sqltype)
135 switch(_sqltype & ~1) {
137 size =
sizeof(short);
143 size =
sizeof(ISC_INT64);
146 size =
sizeof(float);
149 size =
sizeof(double);
152 size =
sizeof(ISC_DATE);
155 size =
sizeof(ISC_TIME);
158 size =
sizeof(ISC_TIMESTAMP);
160#if defined(FIREBIRD_IBASE_H) && FB_API_VER >= 40
162 size =
sizeof(ISC_TIME_TZ_EX);
164 case SQL_TIMESTAMP_TZ_EX:
165 size =
sizeof(ISC_TIMESTAMP_TZ_EX);
172 size =
sizeof(short);
175 size =
sizeof(ISC_QUAD);
178 __DCL_TRACE3(
__T(
"_offset[%d] _sqltype[%d] [%d]\n"), _offset, _sqltype, _sqltype & ~1);
182 return (_offset + size - 1) & ~(size - 1);
189 && (Query::__fieldCount == 0)
192 ISC_STATUS* statusVector = conn()->statusVector();
194 __outSQLDA = (XSQLDA*)malloc(XSQLDA_LENGTH(1));
198 if(isc_dsql_describe(
219 if (isc_dsql_describe(
240 for(
size_t i = 0; i < Query::__fieldCount; i++, sqlvar++) {
241 offset = __TYPE_ALIGN(offset, sqlvar->sqltype);
242 switch(sqlvar->sqltype & ~1) {
244 offset += sqlvar->sqllen + 1;
247 offset += sqlvar->sqllen +
sizeof(short) + 1;
250 offset += sqlvar->sqllen;
265 for(
size_t i = 0; i < Query::__fieldCount; i++, sqlvar++) {
266 offset = __TYPE_ALIGN(offset, sqlvar->sqltype);
268 switch(sqlvar->sqltype & ~1) {
270 offset += sqlvar->sqllen + 1;
273 offset += sqlvar->sqllen +
sizeof(short) + 1;
276 offset += sqlvar->sqllen;
279 if (!
__fields[i].init(
this, sqlvar))
288 ISC_STATUS* statusVector = conn()->statusVector();
290 __inSQLDA = (XSQLDA*)malloc(XSQLDA_LENGTH(1));
294 if (isc_dsql_describe_bind(
315 if (isc_dsql_describe_bind(
328 Query::__paramCount = _paramCount;
336 for(
size_t i = 0; i < Query::__paramCount; i++, sqlvar++) {
337 if (!
__params[i].init(
this, sqlvar)) {
345static char stmt_info_item[] = { isc_info_sql_stmt_type };
346static char count_info_item[] = { isc_info_sql_records };
357 if (isc_dsql_allocate_statement(
367#ifdef FIREBIRD_IBASE_H
372 ISC_STATUS rs = isc_dsql_prepare(
388 if (isc_dsql_sql_info(
391 sizeof(stmt_info_item),
401 if (res_buffer[0] != isc_info_sql_stmt_type) {
406 int len = isc_vax_integer(&res_buffer[1], 2);
411 || (
__stmtType == isc_info_sql_stmt_select_for_upd)
412 || (
__stmtType == isc_info_sql_stmt_exec_procedure)) {
417 if (_paramCount > 0) {
431 if (
__stmtType == isc_info_sql_stmt_exec_procedure) {
435 if (isc_dsql_execute2(
447 if (isc_dsql_execute(
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(
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(conn()->statusVector(),
548 for(
size_t i = 0; i < Query::__fieldCount; i++) {
554 else if (rs == 100) {
567 __DCL_ASSERT((0 <= _index) && (_index < Query::__fieldCount));
568 *_fieldHandleOut = &
__fields[_index];
575 __DCL_ASSERT((0 <= _index) && (_index < Query::__paramCount));
576 *_paramHandleOut = &
__params[_index];
#define SQLDA_CURRENT_VERSION
#define _IB_STMT_TYPE_UNKNOWN
#define __DCL_TRACE0(psz)
#define __DCL_TRACE1(fmt, arg1)
#define __DCL_TRACE3(fmt, arg1, arg2, arg3)
#define __DCL_ASSERT(expr)
#define IMPLEMENT_CLASSINFO(class_name, base_class_name)
#define __SET_ERROR(_errorCode)
void CharsetConvertException *size_t n
isc_tr_handle * trHandlePtr()
ISC_STATUS * statusVector()
isc_db_handle * dbHandlePtr()
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