📄 result.cpp
字号:
b_type != eDB_VarBinary && b_type != eDB_Binary && b_type != eDB_VarChar && b_type != eDB_Char && b_type != eDB_LongChar && b_type != eDB_LongBinary) { throw CDB_ClientEx(eDB_Error, 130020, "CTL_***Result::GetItem", "Wrong type of CDB_Object"); } char* v = fmt.maxlength < 2048 ? buffer : new char[fmt.maxlength + 1]; switch ( my_ct_get_data(cmd, item_no, v, fmt.maxlength, &outlen) ) { case CS_SUCCEED: case CS_END_ITEM: case CS_END_DATA: { v[outlen] = '\0'; if ( item_buf) { if ( outlen <= 0) { item_buf->AssignNULL(); } else { switch ( b_type ) { case eDB_VarChar: *((CDB_VarChar*) item_buf) = v; break; case eDB_Char: *((CDB_Char*) item_buf) = v; break; case eDB_LongChar: *((CDB_LongChar*) item_buf) = v; break; case eDB_VarBinary: ((CDB_VarBinary*) item_buf)->SetValue(v, outlen); break; case eDB_Binary: ((CDB_Binary*) item_buf)->SetValue(v, outlen); break; case eDB_LongBinary: ((CDB_LongBinary*) item_buf)->SetValue(v, outlen); break; default: break; } } if ( v != buffer) delete[] v; return item_buf; } CDB_VarChar* val = (outlen == 0) ? new CDB_VarChar() : new CDB_VarChar(v, (size_t) outlen); if (v != buffer) delete[] v; return val; } case CS_CANCELED: { if (v != buffer) delete[] v; throw CDB_ClientEx(eDB_Error, 130004, "CTL_***Result::GetItem", "the command has been canceled"); } default: { if (v != buffer) delete[] v; throw CDB_ClientEx(eDB_Error, 130000, "CTL_***Result::GetItem", "ct_get_data failed"); } } } case CS_LONGCHAR_TYPE: { if (item_buf && b_type != eDB_LongChar && b_type != eDB_LongBinary) { throw CDB_ClientEx(eDB_Error, 130020, "CTL_***Result::GetItem", "Wrong type of CDB_Object"); } char* v = fmt.maxlength < 2048 ? buffer : new char[fmt.maxlength + 1]; switch ( my_ct_get_data(cmd, item_no, v, fmt.maxlength, &outlen) ) { case CS_SUCCEED: case CS_END_ITEM: case CS_END_DATA: { v[outlen] = '\0'; if ( item_buf) { if ( outlen <= 0) { item_buf->AssignNULL(); } else { switch ( b_type ) { case eDB_LongChar: *((CDB_LongChar*) item_buf) = v; break; case eDB_LongBinary: ((CDB_LongBinary*) item_buf)->SetValue(v, outlen); break; default: break; } } if ( v != buffer) delete[] v; return item_buf; } CDB_LongChar* val = (outlen == 0) ? new CDB_LongChar(fmt.maxlength) : new CDB_LongChar((size_t) outlen, v); if (v != buffer) delete[] v; return val; } case CS_CANCELED: { if (v != buffer) delete[] v; throw CDB_ClientEx(eDB_Error, 130004, "CTL_***Result::GetItem", "the command has been canceled"); } default: { if (v != buffer) delete[] v; throw CDB_ClientEx(eDB_Error, 130000, "CTL_***Result::GetItem", "ct_get_data failed"); } } } case CS_DATETIME_TYPE: { if (item_buf && b_type != eDB_DateTime) { throw CDB_ClientEx(eDB_Error, 130020, "CTL_***Result::GetItem", "Wrong type of CDB_Object"); } CS_DATETIME v; switch ( my_ct_get_data(cmd, item_no, &v, (CS_INT) sizeof(v), &outlen) ) { case CS_SUCCEED: case CS_END_ITEM: case CS_END_DATA: { if ( item_buf) { if ( outlen > 0) { ((CDB_DateTime*)item_buf)->Assign(v.dtdays, v.dttime); } else { item_buf->AssignNULL(); } return item_buf; } CDB_DateTime* val; if ( outlen > 0) { val = new CDB_DateTime(v.dtdays, v.dttime); } else { val = new CDB_DateTime; } return val; } case CS_CANCELED: { throw CDB_ClientEx(eDB_Error, 130004, "CTL_***Result::GetItem", "the command has been canceled"); } default: { throw CDB_ClientEx(eDB_Error, 130000, "CTL_***Result::GetItem", "ct_get_data failed"); } } } case CS_DATETIME4_TYPE: { if (item_buf && b_type != eDB_SmallDateTime && b_type != eDB_DateTime) { throw CDB_ClientEx(eDB_Error, 130020, "CTL_***Result::GetItem", "Wrong type of CDB_Object"); } CS_DATETIME4 v; switch ( my_ct_get_data(cmd, item_no, &v, (CS_INT) sizeof(v), &outlen) ) { case CS_SUCCEED: case CS_END_ITEM: case CS_END_DATA: { if ( item_buf) { if (outlen > 0) { switch ( b_type ) { case eDB_SmallDateTime: ((CDB_SmallDateTime*) item_buf)->Assign (v.days, v.minutes); break; case eDB_DateTime: ((CDB_DateTime*) item_buf)->Assign (v.days, v.minutes * 60 * 300); break; default: break; } } else { item_buf->AssignNULL(); } return item_buf; } return (outlen <= 0) ? new CDB_SmallDateTime : new CDB_SmallDateTime(v.days, v.minutes); } case CS_CANCELED: { throw CDB_ClientEx(eDB_Error, 130004, "CTL_***Result::GetItem", "the command has been canceled"); } default: { throw CDB_ClientEx(eDB_Error, 130000, "CTL_***Result::GetItem", "ct_get_data failed"); } } } case CS_TINYINT_TYPE: { if (item_buf && b_type != eDB_TinyInt && b_type != eDB_SmallInt && b_type != eDB_Int) { throw CDB_ClientEx(eDB_Error, 130020, "CTL_***Result::GetItem", "Wrong type of CDB_Object"); } CS_TINYINT v; switch ( my_ct_get_data(cmd, item_no, &v, (CS_INT) sizeof(v), &outlen) ) { case CS_SUCCEED: case CS_END_ITEM: case CS_END_DATA: { if ( item_buf ) { if (outlen == 0) { item_buf->AssignNULL(); } else { switch ( b_type ) { case eDB_TinyInt: *((CDB_TinyInt*) item_buf) = (Uint1) v; break; case eDB_SmallInt: *((CDB_SmallInt*) item_buf) = (Int2) v; break; case eDB_Int: *((CDB_Int*) item_buf) = (Int4) v; break; default: break; } } return item_buf; } return (outlen == 0) ? new CDB_TinyInt() : new CDB_TinyInt((Uint1) v); } case CS_CANCELED: { throw CDB_ClientEx(eDB_Error, 130004, "CTL_***Result::GetItem", "the command has been canceled"); } default: { throw CDB_ClientEx(eDB_Error, 130000, "CTL_***Result::GetItem", "ct_get_data failed"); } } } case CS_SMALLINT_TYPE: { if (item_buf && b_type != eDB_SmallInt && b_type != eDB_Int) { throw CDB_ClientEx(eDB_Error, 130020, "CTL_***Result::GetItem", "Wrong type of CDB_Object"); } CS_SMALLINT v; switch ( my_ct_get_data(cmd, item_no, &v, (CS_INT) sizeof(v), &outlen) ) { case CS_SUCCEED: case CS_END_ITEM: case CS_END_DATA: { if ( item_buf ) { if (outlen == 0) { item_buf->AssignNULL(); } else { switch ( b_type ) { case eDB_SmallInt: *((CDB_SmallInt*) item_buf) = (Int2) v; break; case eDB_Int: *((CDB_Int*) item_buf) = (Int4) v; break; default: break; } } return item_buf; } return (outlen == 0) ? new CDB_SmallInt() : new CDB_SmallInt((Int2) v); } case CS_CANCELED: { throw CDB_ClientEx(eDB_Error, 130004, "CTL_***Result::GetItem", "the command has been canceled"); } default: { throw CDB_ClientEx(eDB_Error, 130000, "CTL_***Result::GetItem", "ct_get_data failed"); } } } case CS_INT_TYPE: { if (item_buf && b_type != eDB_Int) { throw CDB_ClientEx(eDB_Error, 130020, "CTL_***Result::GetItem", "Wrong type of CDB_Object"); } CS_INT v; switch ( my_ct_get_data(cmd, item_no, &v, (CS_INT) sizeof(v), &outlen) ) { case CS_SUCCEED: case CS_END_ITEM: case CS_END_DATA: { if ( item_buf ) { if (outlen == 0) { item_buf->AssignNULL(); } else { *((CDB_Int*) item_buf) = (Int4) v; } return item_buf; } return (outlen == 0) ? new CDB_Int() : new CDB_Int((Int4) v); } case CS_CANCELED: { throw CDB_ClientEx(eDB_Error, 130004, "CTL_***Result::GetItem", "the command has been canceled"); } default: { throw CDB_ClientEx(eDB_Error, 130000, "CTL_***Result::GetItem", "ct_get_data failed"); } } } case CS_DECIMAL_TYPE: case CS_NUMERIC_TYPE: { if (item_buf && b_type != eDB_BigInt && b_type != eDB_Numeric) { throw CDB_ClientEx(eDB_Error, 130020, "CTL_***Result::GetItem", "Wrong type of CDB_Object"); } CS_NUMERIC v; switch ( my_ct_get_data(cmd, item_no, &v, (CS_INT) sizeof(v), &outlen) ) { case CS_SUCCEED: case CS_END_ITEM: case CS_END_DATA: { if ( item_buf ) { if (outlen < 3) { /* it used to be == 0 but ctlib on windows returns 2 even for NULL numeric */ item_buf->AssignNULL(); } else { if (b_type == eDB_Numeric) { ((CDB_Numeric*) item_buf)->Assign ((unsigned int) v.precision, (unsigned int) v.scale, (const unsigned char*) v.array); } else { *((CDB_BigInt*) item_buf) = numeric_to_longlong((unsigned int) v.precision, v.array); } } return item_buf; } if (fmt.scale == 0 && fmt.precision < 20) { return (outlen == 0) ? new CDB_BigInt : new CDB_BigInt(numeric_to_longlong((unsigned int) v.precision,v.array)); } else { return (outlen == 0) ? new CDB_Numeric : new CDB_Numeric((unsigned int) v.precision, (unsigned int) v.scale, (const unsigned char*) v.array); } } case CS_CANCELED: { throw CDB_ClientEx(eDB_Error, 130004, "CTL_***Result::GetItem", "the command has been canceled"); } default: { throw CDB_ClientEx(eDB_Error, 130000, "CTL_***Result::GetItem", "ct_get_data failed"); } } } case CS_FLOAT_TYPE: { if (item_buf && b_type != eDB_Double) { throw CDB_ClientEx(eDB_Error, 130020, "CTL_***Result::GetItem",
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -