Problem: There is no documented api to get the count of deleted records. Solution: IB 4.x Deej provided the following example to perform the task described above. Here is the example: --------------------- #include#include #include #include long dbStatus[32], SQLCODE; void tsetsqlcode(char *msg) { SQLCODE=isc_sqlcode(dbStatus); if (SQLCODE) { fprintf(stderr, "SQL err %ld doing %sn", SQLCODE, msg); exit(1); } } int main() { isc_db_handle db= 0; isc_tr_handle tr= 0; isc_stmt_handle stmt= 0; char sqlstring[50], cnt_info[2], string[1024], count_type, *ptr; short l; long count; strcpy(sqlstring, "testdb.db"); (void) isc_attach_database(dbStatus, 0, sqlstring, &db, 0, 0); tsetsqlcode("opening db"); (void) isc_start_transaction(dbStatus, &tr, 1, &db, 0, 0); tsetsqlcode("starting transaction"); strcpy(sqlstring, "delete from testfuncs"); /* first do this a way that works, and demo count problem */ (void) isc_dsql_allocate_statement(dbStatus, &db, &stmt); tsetsqlcode("allocating statement"); (void) isc_dsql_prepare(dbStatus, &tr, &stmt, 0, sqlstring, 1, 0); tsetsqlcode("preparing statement"); (void) isc_dsql_execute(dbStatus, &tr, &stmt, 1, 0); tsetsqlcode("executing statement"); cnt_info[0]= isc_info_sql_records; cnt_info[1]= isc_info_end; /* added per suggestion by Deej */ (void) isc_dsql_sql_info(dbStatus, &stmt, sizeof(cnt_info), cnt_info, sizeof(string), string); for (ptr = string + 3; *ptr != isc_info_end; ) { count_type = *ptr++; l = isc_vax_integer (ptr, 2); ptr += 2; count = isc_vax_integer (ptr, l); ptr += l; switch (count_type) { case isc_info_req_update_count: printf ("Records updated: %ldn", count); break; case isc_info_req_delete_count: printf ("Records deleted: %ldn", count); break; case isc_info_req_select_count: printf ("Records retrieved: %ldn", count); break; case isc_info_req_insert_count: printf ("Records inserted: %ldn", count); break; } } if (string[0]==isc_info_error) fprintf(stdout, "No surprise here - I did not get the silly 0 countn"); (void) isc_commit_transaction(dbStatus, &tr); tsetsqlcode("commit"); (void) isc_detach_database(dbStatus, &db); tsetsqlcode("closing db"); exit(0); } ---------------------------- Simple copy the above codes to a file and compile it and link it. For examples on Solaris: tester.c is the file containing the above codes. pooka%cc -c -w tester.c ==>produce file tester.o pooka%cc tester.o -o tester -lgdsmt -lsocket -lthread -lnsl -ldl pooka%tester
Last Modified: 27-OCT-00