Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.tools -> Autoincrement primary-key and JDBC

Autoincrement primary-key and JDBC

From: Peter Döring <peterd_at_gmx.de>
Date: 2000/05/08
Message-ID: <8f6m8j$ed8$1@sun27.hrz.tu-darmstadt.de>#1/1

Hi,

I have a database table with an autoincrement-primary-key realized with a sequence and a trigger (see below).
Everything works fine on an insert.
But how can I access/determine the generated value via JDBC? I hope there is someone out there who can help me.

So, thanks in advance
Peter



SQL-Statement to create the sequence and the trigger the tables name is 'test_table' with the primary-key "nr"

create sequence test_table_seq
 increment by 1
 start with 1
 minvalue 1
 nomaxvalue
 nocycle
 nocache
 noorder
;

create or replace trigger test_table_tr
before insert on test_table
for each row
begin
 if
  :NEW.nr is null
 then
  select test_table_seq.nextval
  into :NEW.nr
  from dual;
 end if;
end; Received on Mon May 08 2000 - 00:00:00 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US