-- get name of sequence from which trigger is taking NEXTVAL.
(you can easily do it by:
"select sequence_for_invoice from our_dba where
our_dba is not in_lunch")
-- write the row giving any (or empty) ID, it will be rewritten.
-- get ID from "select seq_invoice_id.curval from dual".
this is concurrency-safe only from "synchronized" java method
and NO OTHER processes insert into this table.
Concurrency-safe methods even without synchronization would be:
-- No insert trigger.
-- read "select seq_invoice_id.nextval from dual"
-- set this id for new row and insert row
-- be sure all OTHER processes read nextval first before insert
-- use interesting oracle feature "select returning"
-- at least in oracle 816 this syntax was not yet supported by
oracle's jdbc driver.
-- one can easily make stored procedure taking invoice data,
inserting and returning id, (with or without "select returning")
But store procedures will move you away from
> How do you refresh the "insertRow" of an updatable ResultSet
> Oracle 8.1.7 JDBC)?
> Example: I use an updatable ResultSet to insert an Invoice table record
> know has a trigger to assign the InvoiceNumber). I then need to refresh
> insertRow so that I may see the assigned InvoiceNumber and use that to
> If my code has to assign the InvoiceNumber first (ie I can't refresh the
> am, at best duplicating the trigger code (maintenance headaches, etc.) or
> circumventing the trigger and possibly violating database constraints.