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: stephen O'D <stephen.odonnell_at_gmail.com>
Date: 1 Mar 2005 06:01:02 -0800
Message-ID: <1109685662.584256.27320@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;
/

the output will be

1
2
3
...
etc.

Obviously you can build the PL/SQL block into a proper procedure etc. Received on Tue Mar 01 2005 - 08:01:02 CST

Original text of this message

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