Subject | Re: transactions in embedded sql |
---|---|
Author | synecticsza |
Post date | 2002-05-15T08:16:09Z |
Peter,
The problem lies in your COMMIT/ROLLBACK statements. You are using:
EXEC SQL COMMIT HtransIns;
while you should be using
EXEC SQL COMMIT TRANSACTION HtransIns;
If you look at the generated C code, you will see that the first one
tries to commit the default transaction (gds_trans), while the second
way commits your named transaction.
The GPRE preprocessor does not catch all syntax errors, so it can be
a bit of a struggle to find things like this :-)
I would have done one or two things differently, such as initialising
the transaction handles to NULL directly before starting a
transaction. This may not be a problem, since I don't really know the
flow of your app.
Secondly, I would not have bothered with a separate transaction for
obtaining the primary key, but that's not really an issue.
BTW, the -m switch is relevant not because your transactions are
named, but because you are starting your own transactions, named or
not.
Vince
The problem lies in your COMMIT/ROLLBACK statements. You are using:
EXEC SQL COMMIT HtransIns;
while you should be using
EXEC SQL COMMIT TRANSACTION HtransIns;
If you look at the generated C code, you will see that the first one
tries to commit the default transaction (gds_trans), while the second
way commits your named transaction.
The GPRE preprocessor does not catch all syntax errors, so it can be
a bit of a struggle to find things like this :-)
I would have done one or two things differently, such as initialising
the transaction handles to NULL directly before starting a
transaction. This may not be a problem, since I don't really know the
flow of your app.
Secondly, I would not have bothered with a separate transaction for
obtaining the primary key, but that's not really an issue.
BTW, the -m switch is relevant not because your transactions are
named, but because you are starting your own transactions, named or
not.
Vince
--- In ib-support@y..., Peter Faulks <pfaulks@c...> wrote:
> G'day
>
> Having a few problems with transactions in embedded sql:
>
> C++Builder / FB1
>
> I declare 3 transaction handles, 1 for select (read only), 1 for the
> primary key generation, and on for inserts. These are initialised
to NULL
> on connection.
>
> EXEC SQL BEGIN DECLARE SECTION;
> //other host vars....
> isc_tr_handle HtransIns, HtransSel, Htrans_genId;
[SNIP]
> if(! SQLCODE)
> {
> EXEC SQL COMMIT Htrans_genId;
> return(HpkId);
> }