Subject GPRE/API Different with FB 1.5?
Author ericboyajian
I have a C++ program with ESQL commands that I process using GPRE. I
just downloaded FB 1.5 with the expectation of upgrading to it;
however, there seems to be a difference between FB 1.0 and 1.5 that
is causing giving me a problem.


My program does the following:
ESQL C++ code snippet =================================

EXEC SQL
CONNECT DB USER 'SYSDBA' PASSWORD 'masterkey';

gds_trans = (isc_tr_handle) 0;
EXEC SQL
SET TRANSACTION NAME gds_trans;

sqlda = (XSQLDA*) malloc(XSQLDA_LENGTH (150));
sqlda->version = SQLDA_VERSION1;
sqlda->sqln = 150;

EXEC SQL
PREPARE TRANSACTION gds_trans Q1 INTO sqlda FROM :string;

end of ESQL C++ code ==================================


This gets GPREed into:

GPRE output snippet ===================================

/*EXEC SQL
CONNECT DB USER 'SYSDBA' PASSWORD 'masterkey';*/
{
isc_2p = (char*) 0;
isc_expand_dpb (&isc_2p, &isc_2l, isc_dpb_user_name, "SYSDBA",
isc_dpb_password, "masterkey", isc_dpb_sql_role_name, (char*) 0,
isc_dpb_lc_messages, (char*) 0, isc_dpb_lc_ctype, (char*) 0, 0);
isc_attach_database (isc_status, 0, db_name, &DB, isc_2l, isc_2p);
isc_free ((char*) isc_2p);
isc_2l = 0;
SQLCODE = isc_sqlcode (isc_status);
}

gds_trans = (isc_tr_handle) 0;
/*EXEC SQL
SET TRANSACTION NAME gds_trans;*/
{
isc_start_transaction (isc_status, (FRBRD**) &gds_trans, (short) 1,
&DB, (short) 4, isc_tpb_0);
SQLCODE = isc_sqlcode (isc_status);
}

sqlda = (XSQLDA*) malloc(XSQLDA_LENGTH (150));
sqlda->version = SQLDA_VERSION1;
sqlda->sqln = 150;

/*EXEC SQL
PREPARE TRANSACTION gds_trans Q1 INTO sqlda FROM :string;*/
{
isc_embed_dsql_prepare (isc_status, &DB, &gds_trans, "Q1", 0, string,
3, sqlda);
SQLCODE = isc_sqlcode (isc_status);
}

end of GPRE output ==================================


With FB 1.0, this worked fine with the final SQLCODE == 0.

With FB 1.5, the final SQLCODE == -901. The error code is 335544332,
which means:
Invalid transaction handle (expecting explicit transaction start)

Each of the prior API calls returns an SQLCODE == 0. Is there
something I need to do before I prepare the transaction?

Sorry for the long post. Thanks.

Eric