Subject | Re: [firebird-support] Re: What API do you use to get affected row count? |
---|---|
Author | Dimitry Sibiryakov |
Post date | 2006-04-27T04:58:40Z |
On 26 Apr 2006 at 13:33, Jeff Lynn wrote:
can find it "Requesting information about an attachment" chapter of
API guide.
small.
char Items = isc_info_sql_records;
char Buffer[40];
FB_Call(fb_dsql_sql_info(status, &(CurStatement->Handle),
1, &Items, sizeof(Buffer), Buffer),
"TFBDB::ExecuteUpdate - get info");
char* p = Buffer;
char item = *p++;
if (item == isc_info_sql_records)
{
int length = fb_portable_integer(p, 2);
p += 2;
while ((item = *p++) != isc_info_end)
{
length = fb_portable_integer(p, 2);
p+=2;
if(item == isc_info_req_update_count)
{
/*This is the value we want - No of Rows Affected */
int value = fb_portable_integer(p, length);
return value;
}
p += length;
}
}
--
SY, Dimitry Sibiryakov.
>I found the isc_info_sql_records from the ibase.h. Interesting thatThis is an old addition. Borland API documentation is incomplete.
>it is nowhere to be found in the API doc from Interbase. Must be a
>new addition to Firebird after Interbase 6.5.
>Since I don't know the definition of the returned info, I dumped all 8All *_info() functions has the same format of returning data. You
>bytes of the buffer, and got the following:
>
> 2ffffffccffffffccffffffccffffffccffffffccffffffccffffffcc
can find it "Requesting information about an attachment" chapter of
API guide.
>I assume the first byte returned " 2" is the number of affected rows.In your case "2" is "isc_info_truncated" const. Buffer is too
small.
>Any idea?Here is complete example of getting number of updated records:
char Items = isc_info_sql_records;
char Buffer[40];
FB_Call(fb_dsql_sql_info(status, &(CurStatement->Handle),
1, &Items, sizeof(Buffer), Buffer),
"TFBDB::ExecuteUpdate - get info");
char* p = Buffer;
char item = *p++;
if (item == isc_info_sql_records)
{
int length = fb_portable_integer(p, 2);
p += 2;
while ((item = *p++) != isc_info_end)
{
length = fb_portable_integer(p, 2);
p+=2;
if(item == isc_info_req_update_count)
{
/*This is the value we want - No of Rows Affected */
int value = fb_portable_integer(p, length);
return value;
}
p += length;
}
}
--
SY, Dimitry Sibiryakov.