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

Home -> Community -> Usenet -> c.d.o.server -> autonumber with trigger and/or sequence

autonumber with trigger and/or sequence

From: whitsmore <no email>
Date: 26 May 2002 04:47:14 -0500
Message-ID: <k461fu09n98dfirvq5viph7h23tbei9lru@4ax.com>


I'm stumped. I'm new to oracle and wanted to do something that MS access does. Access will generate a primary key with an autonumber. So, I've read past threads on google and I'm just missing something. To make it simplier for someone to answer, I will recreate step-by-step. Maybe someone can pick apart my problem.

I created a table called TEST in AMY schema and PK being primary key:

CREATE TABLE "AMY"."TEST" ("PK" NUMBER(7) NOT NULL, "PART"     VARCHAR2(10) NOT NULL, "DESC" VARCHAR2(10) NOT NULL, PRIMARY     KEY("PK")) I created sequence called seq_pk:

Create sequence s_pk
Increment by 1
start with 1
maxvalue 9999999
nocache
nocycle;

I created trigger called tr_pk:

create of replace trigger amy.tr_pk before insert on amy.test for each row begin
select seq_pk.nextval into :new.pk from test; end;

So, here's my problem. When I use MS access as a frontend (linked to Oracle table called TEST, I get the following error:

The field is too small to accept the amount of data you attempted to add. Try inserting or pasting less data.

When I use the the OEM, right click on TEST, table editor, I enter in the value for part and desc and leave pk blank. When I click on apply, I get an error message of:

ORA-01403: no data found
ORA-06512: at "amy.TR_PK", line 2
ORa-04088: error during execution of trigger'amy.tr_pk'

So, how do I get the PK field to use an autonumber. TIA Received on Sun May 26 2002 - 04:47:14 CDT

Original text of this message

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