Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Simple and URGENT!
Message
Information générale
Forum:
Oracle
Catégorie:
Déclencheurs, séquences et procédures stockées
Divers
Thread ID:
00624480
Message ID:
00624705
Vues:
11
>Need some help to create a trigger on a 8i database.
>
>When a user update a record on table X i have to update table Y (that has the same structure that X) with the new values of X.
>
>THIS IS URGENT, PLEASE!
>
>Alonso

Here is a sample trigger:
create or replace trigger ACTION_TYPE_BEFORE_INSUPDT
before insert or update on npdes.ACTION_TYPE for each row
declare
v_Id Number;
BEGIN
 If :new.KeyID Is Null or :new.KeyID < 1 Then
 select s_npdes_ACTION_TYPE.nextval into v_Id from dual;
 :new.KeyID := v_Id;
End If;
End;
/
To modify mine, put your UPDATE - SQL after the End If line. The first part generates the PK if this is an insert or the records does not have a valid PK [this should never happen except for an insert]. Your update might look like:

update TableY set field1 = :new.field1, field2 = :new.field2 where keyid = :new.keyid;

:new.field1, :new.field2, etc., are the new values coming into TableX to be updated.
Mark McCasland
Midlothian, TX USA
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform