Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQLExec Help Desperate!
Message
General information
Forum:
Visual FoxPro
Category:
Client/server
Miscellaneous
Thread ID:
00462163
Message ID:
00462339
Views:
13
>Sooo..... Do you have any example syntax (pseudocode?) for creating an insert trigger and/or a sequence?

The following is form a filename.SQL script [text] file. All my tables have columns named UPDATED_BY and LAST_UPDATE, so those two lines [:new.Updated and :new.Last_Update] can be removed if they do not exist in the table being updated.
create sequence s_npdes_WATERBODY  increment by 1 start with 1 nocache;

create or replace trigger WATERBODY_BEFORE_INSUPDT
 BEFORE INSERT OR UPDATE ON NPDES.WATERBODY FOR EACH ROW
DECLARE
 v_Id    Number;
 v_Count Number;
BEGIN
 :new.Updated_By  := USER;
 :new.Last_Update := SYSDATE;
 IF :new.KeyID Is Null or :new.KeyID < 1 THEN
    select s_npdes_WATERBODY.nextval into v_Id from dual;
    :new.KeyID := v_Id;
 END IF;
END;
/
If you have users connecting to Oracle using their own user ID, you have to grant them SELECT privileges on any sequences. You also need to create public synonyms for all the table names and sequence names.
Mark McCasland
Midlothian, TX USA
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform