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

Home -> Community -> Usenet -> c.d.o.misc -> Re: oracle 8 and auto increment

Re: oracle 8 and auto increment

From: Frank van Bortel <fvanbortel_at_netscape.net>
Date: Tue, 01 Mar 2005 17:37:23 +0100
Message-ID: <d025jp$bft$1@news1.zwoll1.ov.home.nl>


Thorsten Ottosen wrote:
> "stephen O'D" <stephen.odonnell_at_gmail.com> wrote in message
> news:1109685662.584256.27320_at_l41g2000cwc.googlegroups.com...
> | Something like this will work:-
> |
> | create sequence mytestseq start with 1 increment by 1 minvalue 1;
> |
> | create table t (id integer, text varchar2(50));
> |
> | set serveroutput on
> |
> | declare
> | new_id integer;
> | begin
> | insert into t (id, text) values (mytestseq.nextval,'test entry')
> | returning id into new_id;
> |
> | dbms_output.put_line (new_id);
> | end;
>
> Thanks! I was able extract the number by
>
> select mytestseq.currval from dual;
>
> -Thorsten
>
>

Watch out with that - it will only work if you did use a nextval in the same session.

Another comment: why "upgrade" to an ancient, no longer supported version of Oracle? More recent versions also know the 'returning' clause:
http://download-west.oracle.com/docs/cd/B14117_01/appdev.101/b10807/13_elems014.htm#i33716

-- 
Regards,
Frank van Bortel
Received on Tue Mar 01 2005 - 10:37:23 CST

Original text of this message

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