Re: OH NO, NOT ORACLE!!
Posted in 1996
On 5 Jul 1996 14:08:22 -0400, rob@dssmktg.com (Robert Minter) wrote:
>Hi all,
>
>Unfortunately, we are porting one of our products to also handle Oracle
>DBs.
>
>Is there, any of you ex- or current Oracle users, know how to implement
>something similar to the Informix SERIAL field type?
I'm an ex-informix user but....
To implement something similar to an Informix Serial type you would:
create table mytable
( x int primary key,
y ....
)/
create sequence mytable_seq/
create or replace trigger mytable_bifer
before insert on mytable
foreach row
begin
select mytable_seq.nextval into :new.x from dual;
end;
/
You can use an Oracle sequence number to generate the primary key for you.
Instead of getting the value of the 'serial' number from the sqlca structure
after the insert, you will "select mytable_seq.currval into :somelocal_variable
from dual".
>
>Emailing directly is not required, but recommended... ;-)
>
>Thanks in advance,
>
>-----------------------------------------------------------------------------
> Robert Minter Data Systems Support
> Senior Software Engineer A Client Technologies Company
> E-Mail: rob@dssmktg.com Tel: 714.771.0454
> Fax: 714.771.3028
>#include <std_disclaimer.h> http://www.dssny.com
Thomas Kyte
Oracle Government
tkyte@us.oracle.com
http://govt.us.oracle.com -- Check out our web site! Brand new, uses Oracle Web Server and Database
-------------------
statements and opinions are mine and do not necessarily
reflect the opinions of Oracle Corporation