db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tony Seebregts <to...@cibecs.com>
Subject Generated Keys and Triggers
Date Thu, 29 Sep 2005 09:22:30 GMT
Hi,

If I execute a statement that inserts a row into a table that has an 
attached trigger that inserts a row into another table I get anomalous 
results when trying to retrieve the generated keys using 
statement.getGeneratedKeys():

1. If the first table does not generate a key (because the generated key 
column was supplied) then getGeneratedKeys() returns the generated key 
for the row inserted by the trigger.

2. If the first table doe not generate a key (because the generated key 
column was not supplied or has a DEFAULT value) then getGeneratedKeys() 
returns only the generated key for the first table i.e. not for the row 
inserted by the trigger.

The ResultSetMetadata from the getGeneratedKeys does not contain any 
information other than the number of columns i.e. its impossible to 
determine which generated key is being returned.

Does anybody have a workaround for this ? (other than being *really* 
careful about the database design :-) ).

regards

Tony Seebregts



Mime
View raw message