freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
- From: "David Nsengiyumva" <davidn AT finsolutions.co.za>
- To: <freetds AT lists.ibiblio.org>
- Subject: [freetds] RE: FreeTDS Digest, Vol 11, Issue 14
- Date: Thu, 4 Dec 2003 18:02:41 +0200
Hi Bill
My Loop looks like this
void FTDSQuery::GetResults(void)
{
CS_RETCODE ret;
CS_RETCODE results_ret;
CS_INT result_type;
CS_INT count;
while ((results_ret = ct_results(cmd, &result_type)) == CS_SUCCEED) {
switch ((int) result_type) {
case CS_CMD_SUCCEED:
//GetRowCount();
break;
case CS_CMD_DONE:
//GetRowCount();
break;
case CS_CMD_FAIL:
throw Exception("FTDSQuery: ct_results() failed.");
case CS_ROW_RESULT:
if(ct_res_info(cmd, CS_NUMDATA, &FieldCount,
CS_UNUSED, NULL) !=
CS_SUCCEED)
throw FTDSException("ct_res_info() failed");
Rows->Clear();
do
{
AddRow();
ret = ct_fetch(cmd, CS_UNUSED, CS_UNUSED, CS_UNUSED, &count);
}
while((ret == CS_SUCCEED));
switch ((int) ret) {
case CS_END_DATA:
break;
case CS_ROW_FAIL:
throw Exception("ct_fetch() returned CS_ROW_FAIL.");
case CS_FAIL:
throw Exception("ct_fetch() returned CS_FAIL.");
default:
throw Exception("ct_fetch() unexpected return.");
} // switch
Rows->CurrentRow = 0; // Rows is just a class that
uses a 2D
STL vector to
RowCount = Rows->Rows.size(); // store rows results
return;
case CS_COMPUTE_RESULT:
throw Exception("ct_results() unexpected
CS_COMPUTE_RESULT.");
case CS_SUCCEED:
throw Exception("ct_results() unexpected CS_COMPUTE_RESULT.");
default:
throw Exception("ct_results() expected result_type.
Just testing");
} // switch
} // while
switch ((int) results_ret) {
case CS_END_RESULTS:
break;
case CS_FAIL:
throw Exception("ct_results() failed.");
default:
throw Exception("ct_results() unexpected return.");
} // switch
}
>>Hey david,
>>
>>your problem is that you haven't fully processed the result set from your
>>previous command that is accessing sysobjects, syscolumns etc.
>>
>>
>>You are doing a ct_results() and then a ct_fetch(), but you haven't fully
>>processed the result set before issuing your "exec stored proc" command.
>>You need to call ct_results in a loop until it returns CS_END_RESULTS
>>
>>see <freetds>/src/ctlib/unittests/t0002.c for an example of a ct_results
>>loop.
>>
>>The CS_RECOMPILE options will force the stored procedure to be recompiled
>>before executing.
>>
>>Bill
-
[freetds] RE: FreeTDS Digest, Vol 11, Issue 14,
David Nsengiyumva, 12/04/2003
- <Possible follow-up(s)>
- RE: [freetds] RE: FreeTDS Digest, Vol 11, Issue 14, Thompson, Bill D (London), 12/04/2003
- RE: [freetds] RE: FreeTDS Digest, Vol 11, Issue 14, Thompson, Bill D (London), 12/04/2003
Archive powered by MHonArc 2.6.24.