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 -> Re: Autoincrement primary-key and JDBC

Re: Autoincrement primary-key and JDBC

From: Bob Fazio <rfazio_at_home.com.nospam>
Date: 2000/05/08
Message-ID: <yeCR4.177526$Tn4.1358104@news1.rdc2.pa.home.com>#1/1

select test_table_seq.currval
into Some_variable
from dual;

--
Robert Fazio, Oracle DBA
rfazio_at_home.com
remove nospam from reply address
http://24.8.218.197/
"Peter Döring" <peterd_at_gmx.de> wrote in message
news:8f6m8j$ed8$1_at_sun27.hrz.tu-darmstadt.de...

> 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