Problem: Looking for a working api example of deleting a record. Solution: Note: this document pertains to InterBase Version 4.x. Here is an api example of deleting a record. 1) Copy and paste the following source into a source file. For example, I can create a file named, test.c, with the following source. -------------------------------------------- #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]; strcpy(sqlstring, "employee.gdb"); tsetsqlcode("opening db"); (void) isc_attach_database(dbStatus, 0, sqlstring, &db, 0, 0); tsetsqlcode("starting transaction"); (void) isc_start_transaction(dbStatus, &tr, 1, &db, 0, 0); tsetsqlcode("executing immed"); strcpy(sqlstring, "delete from sales where po_number = 'V91E0210' "); isc_dsql_execute_immediate(dbStatus, &db, &tr, 0, sqlstring, 1, 0); tsetsqlcode("commit"); (void) isc_commit_transaction(dbStatus, &tr); tsetsqlcode("closing db"); (void) isc_detach_database(dbStatus, &db); exit(0); } ------------------------------------------- Note: Before compile, be sure to have a copy of employee.gdb in the same directory as the source file. 2) Compile and link the source file on your favorite platform. See http://www.interbase.com for more details on compiling and linking on the various platforms. Example of compiling & linking under the Solaris platform: %cc -w -c test.c %cc test.o -o test -lgdsmt -lsocket -lthread -lnsl -ldl 3) Run the program. Example: %test
Last Modified: 17-OCT-00