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;
88 Query::__fieldCount = 0;
96 Query::__paramCount = 0;
114 ISC_STATUS* statusVector = conn()->statusVector();
117 if (isc_dsql_free_statement(
131static size_t __TYPE_ALIGN(
size_t _offset,
int _sqltype)
134 switch(_sqltype & ~1) {
136 size =
sizeof(short);
142 size =
sizeof(ISC_INT64);
145 size =
sizeof(float);
148 size =
sizeof(double);
151 size =
sizeof(ISC_DATE);
154 size =
sizeof(ISC_TIME);
157 size =
sizeof(ISC_TIMESTAMP);
163 size =
sizeof(short);
166 size =
sizeof(ISC_QUAD);
169 __DCL_TRACE3(
__T(
"_offset[%d] _sqltype[%d] [%d]\n"), _offset, _sqltype, _sqltype & ~1);
173 return (_offset + size - 1) & ~(size - 1);
180 && (Query::__fieldCount == 0)
183 ISC_STATUS* statusVector = conn()->statusVector();
185 __outSQLDA = (XSQLDA*)malloc(XSQLDA_LENGTH(1));
189 if(isc_dsql_describe(
210 if (isc_dsql_describe(
231 for(
size_t i = 0; i < Query::__fieldCount; i++, sqlvar++) {
232 offset = __TYPE_ALIGN(offset, sqlvar->sqltype);
233 switch(sqlvar->sqltype & ~1) {
235 offset += sqlvar->sqllen + 1;
238 offset += sqlvar->sqllen +
sizeof(short) + 1;
241 offset += sqlvar->sqllen;
256 for(
size_t i = 0; i < Query::__fieldCount; i++, sqlvar++) {
257 offset = __TYPE_ALIGN(offset, sqlvar->sqltype);
259 switch(sqlvar->sqltype & ~1) {
261 offset += sqlvar->sqllen + 1;
264 offset += sqlvar->sqllen +
sizeof(short) + 1;
267 offset += sqlvar->sqllen;
270 if (!
__fields[i].init(
this, sqlvar))
279 ISC_STATUS* statusVector = conn()->statusVector();
281 __inSQLDA = (XSQLDA*)malloc(XSQLDA_LENGTH(1));
285 if (isc_dsql_describe_bind(
306 if (isc_dsql_describe_bind(
319 Query::__paramCount = _paramCount;
327 for(
size_t i = 0; i < Query::__paramCount; i++, sqlvar++) {
328 if (!
__params[i].init(
this, sqlvar)) {
336static char stmt_info_item[] = { isc_info_sql_stmt_type };
337static char count_info_item[] = { isc_info_sql_records };
348 if (isc_dsql_allocate_statement(
358 ISC_STATUS rs = isc_dsql_prepare(
377 if (isc_dsql_sql_info(
380 sizeof(stmt_info_item),
390 if (res_buffer[0] != isc_info_sql_stmt_type) {
394 nLength = isc_vax_integer(&res_buffer[1], 2);
395 __stmtType = isc_vax_integer(&res_buffer[3], nLength);
399 || (
__stmtType == isc_info_sql_stmt_exec_procedure)
400 || (
__stmtType == isc_info_sql_stmt_select_for_upd)) {
405 if (_paramCount > 0) {
419 if (
__stmtType == isc_info_sql_stmt_exec_procedure) {
420 if (isc_dsql_execute2(
433 if (isc_dsql_execute(
444 for(
size_t i = 0; i < Query::__paramCount; i++)
450 unsigned char count_type = 0;
452 case isc_info_sql_stmt_update: {
453 count_type = isc_info_req_update_count;
456 case isc_info_sql_stmt_delete: {
457 count_type = isc_info_req_delete_count;
460 case isc_info_sql_stmt_insert: {
461 count_type = isc_info_req_insert_count;
464 case isc_info_sql_stmt_select:
465 case isc_info_sql_stmt_select_for_upd: {
466 Query::__eof =
false;
469 case isc_info_sql_stmt_exec_procedure: {
470 for (
size_t i = 0; i < Query::__fieldCount; i++) {
479 unsigned char count_is = 0;
480 char count_buffer[33];
481 unsigned short length;
483 if (isc_dsql_sql_info(
486 sizeof(count_info_item),
488 sizeof(count_buffer),
495 for(
char* pch = count_buffer + 3; *pch != isc_info_end; ) {
497 length = (
unsigned short)isc_vax_integer(pch, 2);
499 Query::__affectedRows = isc_vax_integer(pch, length);
501 if (count_is == count_type)
514 ISC_STATUS rs = isc_dsql_fetch(conn()->statusVector(),
519 for(
size_t i = 0; i < Query::__fieldCount; i++) {
525 else if (rs == 100) {
538 __DCL_ASSERT((0 <= _index) && (_index < Query::__fieldCount));
539 *_fieldHandleOut = &
__fields[_index];
546 __DCL_ASSERT((0 <= _index) && (_index < Query::__paramCount));
547 *_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