Problem: Have an embedded file that gpre and compile okay. But gives invalid database handle error when running it. The SQL code given is -904. This is what is used to gpre and compile: gpre -n stat8a.e bcc32 -v -w -a4 -tWM -DWIN32 -Iborlandintrbaseinclude -tWC stat8a.c borland intrbaselibgds32.lib Note: This is compiling and linking using Borland C++ 5.01. Solution: IB V4.x Modify in the .e file the path "c:testingemployee.gdb" to "c:testingemployee.gdb". And gpre and compile it again. Listed below is the text of a .e file that reproduces the difficulty. /* * Program type: Embedded Static SQL * * Description: * This program performs a simple update to an existing * table, asks the user whether to save the update, and * commits or undoes the transaction accordingly. */ #include "example.h" #include#include int do_save PROTO((void)); void clean_up PROTO((void)); EXEC SQL BEGIN DECLARE SECTION; EXEC SQL SET DATABASE DB1 = "C:TEMPEMPLOYEE.GDB"; EXEC SQL END DECLARE SECTION; int main PROTO((void)) { EXEC SQL CONNECT DB1; clean_up(); /* Insert a new row. */ EXEC SQL INSERT INTO country (country, currency) VALUES ('Mexico', 'Peso'); /* Check the SQLCODE directly */ if (SQLCODE) { isc_print_sqlerror((short)SQLCODE, gds__status); exit(1); } printf("nAdding: country = 'Mexico', currency = 'Peso'nn"); /* Confirm whether to commit the update. */ if (do_save()) { EXEC SQL COMMIT RELEASE; printf("nSAVED.nn"); } else { EXEC SQL ROLLBACK RELEASE; printf("nUNDONE.nn"); } return 0; } /* * Ask the user whether to save the newly added row. */ int do_save PROTO((void)) { char answer[10]; printf("Save? Enter 'y' for yes, 'n' for no: "); gets(answer); return (*answer == 'y' ? 1 : 0); } /* * If this is not the first time this program is run, * the example row may already exist -- delete the example * row in order to avoid a duplicate value error. */ void clean_up PROTO((void)) { EXEC SQL DELETE FROM country WHERE country = 'Mexico'; EXEC SQL COMMIT WORK; }
Last Modified: 29-SEP-00