Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Sequence ERROR
Message
 
 
To
04/01/2001 07:42:45
General information
Forum:
Oracle
Category:
Triggers, Sequences and Stored Procedures
Title:
Miscellaneous
Thread ID:
00459266
Message ID:
00459326
Views:
22
How are you populating your PK field? Manually or with an Insert/Update trigger? A trigger will work far better. Below is sample code of how I use a trigger with a sequence. I also maintain the following SQL or PL/SQL in a text file with a .SQL extension [this is a SQL script file]. Then I launch SQL*Plus and run the script file. From the SQL*Plus prompt, I type:

@c:\path_to_script_files\myscript

where the .SQL extension is implied. In the code below, I also update the data in my Last_Update and Updated_By columns which are in all my tables.
create sequence S_NPDES_ADDRESS_HISTORY
increment by 1
start with 1 nocache;

create or replace trigger ADDRESS_HISTORY_BEFORE_INSUPDT
before insert or update on npdes.ADDRESS_HISTORY for each row
declare
v_Id   Number;
BEGIN
 :new.Updated_By  := USER;
 :new.Last_Update := SYSDATE;
 If :new.KeyID Is Null or :new.KeyID < 1 Then
    select S_NPDES_ADDRESS_HISTORY.nextval into v_Id from dual;
    :new.KeyID := v_Id;
 End If;
End;
/
>Hi everyBody
>
>I work with VB5 and I have DataBase on Oracle 8.
>
>I have Create a sequence
>
>CREATE SEQUENCE IdPoste_Seq
>START 1
>INCREMENT BY 1
>
>
>My Application is a Client/Server and some time two users work with his SEQUENCE and one of them find a Seqence Numnber Invalide.
>
>I Use this Sequence on the primary Key on my Tble POSTE
>
>SomeOne have or had his Erreur
>
>Thanks for your help!
Mark McCasland
Midlothian, TX USA
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform