Re: Simulating autoincrement in Oracle

From: Jim Kennedy <kennedy-family_at_attbi.com>
Date: Fri, 12 Apr 2002 06:58:33 GMT
Message-ID: <tAvt8.210767$Yv2.67686_at_rwcrnsc54>


Yippee! Someone who did some research or read the manuals. Looks great.

Jim
"John" <xertroyt_at_yahoo.com> wrote in message news:1ea65a.0204111804.7549c01c_at_posting.google.com...
> I recently ported some code from DB2 (which has an autoincrement
> feature for column values) and needed to simulate that somehow in
> Oracle.
>
> Here's what I came up with:
>
> create or replace trigger user.table_autoincrement
> before insert on user.table
> for each row
> begin
> if :new.col is null then
> select user.table_s.nextval
> into :new.col
> from dual;
> end if;
> end table_autoincrement;
>
> This seems to work fine, but I was wondering if anyone sees any
> gotchas.
>
> John
Received on Fri Apr 12 2002 - 08:58:33 CEST

Original text of this message