Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Sequence ERROR
Message
 
 
À
04/01/2001 07:42:45
Information générale
Forum:
Oracle
Catégorie:
Déclencheurs, séquences et procédures stockées
Titre:
Divers
Thread ID:
00459266
Message ID:
00459326
Vues:
24
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform