PL/SQL trigger code

Results 1 to 2 of 2

Thread: PL/SQL trigger code

  1. #1
    Join Date
    Dec 1969

    Default PL/SQL trigger code

    How does one write a trigger in PL/SQL to :<BR><BR>get source data such as "turner,vincent", "224 Argonne blvd", "New Orleans, LA 70150", "504-532-2285 " to be transformed to:<BR><BR>LastName: Vincent FirstName: Turner Street: 224 Argonne blvd<BR>City: New Orleans State: LA Zip: 70150 Phone: 504-532-2285 <BR><BR>The trigger is to be written on the insert of Table A(with fields Name, Street, Address, Phone) to load data into table B(with fields First Name,Last Name,Street, City, State, Zip,Phone,Date, User).The date is the sysdate and user is the current username in Oracle.<BR><BR>Thanks.

  2. #2
    Join Date
    Dec 1969

    Default Well this is how you would create

    the trigger<BR><BR>CREATE OR REPLACE TRIGGER mytrigger<BR>AFTER INSERT ON tableA<BR>FOR EACH ROW<BR><BR>BEGIN <BR> IF INSERTING <BR> THEN<BR> INSERT INTO tableB<BR> VALUES (,<BR> :old.street,<BR> :old.address,<BR>,<BR> USER,<BR> SYSDATE);<BR> END IF;<BR>END;<BR>/<BR><BR>However, I only gave you part of it. ; )<BR><BR>You ware going to have to use SUBSTR function(with other functions) to strip out the first and last names, city etc. from the "old" fields.<BR><BR>substr(, ...<BR><BR>Give it a try and if you get into trouble then post and I&#039;ll help some more.<BR><BR>Good luck<BR>Pete

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts