|Subject||Re: [Firebird-Java] Re: returning generated keys|
Actualy I faced the same problem, developing CRM application based on Firebird
I am using sessions and have additional column (for example fresh). Whein I insert a row
I set fresh=0;
then I select all rows with fresh=0 and get the ID (autogenerated) .. then using the ID I set fresh to 1...
all this done in high level of transaction isolation and in one transaction. This works for me
----- Original Message -----From: Roman RokytskyySent: Thursday, March 27, 2003 10:19 AMSubject: [Firebird-Java] Re: returning generated keys> I note that a call to
> Statement.executeUpdate(sql, Statement.RETURN_GENERATED_KEYS)
> currently raises an exception with a 'not yet implemented'
> message. I imagine this has a lot to do with there being
> no 'autoinc' type in firebird? (yes I'm using a trigger and a
You are right. This method does not works because server does not
have autoinc datatype.
> Does anyone have a clever and (most importaintly) portable way of
> doing the same thing? Although we are currently using Firebird for
> development, ultimatly our clients will be making the call as to
> which database the app will run on so we need to keep it all as
> generic as possible.
Split ID generation and statement execution into two separate steps.
You can decide if you want to make these steps visible on the
interface level, or only in the implementation.
Another approach can be creating a stored procedure that performs
insert and returns you generated ID. But in this case you need to use
CallableStatement or PreparedStatement.executeQuery().
To unsubscribe from this group, send an email to:
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.