Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.tools -> Re: Autoincrement primary-key and JDBC
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...Received on Mon May 08 2000 - 00:00:00 CDT
> 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;
>
>
>
>
![]() |
![]() |