Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Assign a table row directly to a record in a trigger

781348Jun 24 2010 — edited Jun 24 2010
Hi There, this may be a dumb question, sorry for my ignorance, but I am wondering if there is anyway I can assign
a table row directly to a record in the trigger. As you can see below I have a variable defined with %ROWTYPE
and then I assign each column individually with := statement. So I have 19 assignment statements below. Is there anyway I can say like this
recLatestreading := new_rec so that all the new values will be assigned to my record in one line of code instead of 19 assignment statements like recLatestRead.miu_id := :new.miu_id etc..



CREATE OR REPLACE TRIGGER trlast_reading
BEFORE UPDATE ON fast.last_reading
REFERENCING new AS new
FOR EACH ROW
DECLARE
recLatestRead LAST_READING%ROWTYPE;
BEGIN

recLatestRead.miu_id := :new.miu_id;
recLatestRead.reader_id := :new.reader_id;
recLatestRead.crew_id := :new.crew_id;
recLatestRead.order_route := :new.order_route;
recLatestRead.collect_method := :new.collect_method;
recLatestRead.collect_type := :new.collect_type;
recLatestRead.reading := :new.field1;
recLatestRead.extra_data := :new.extra_data;
recLatestRead.skip_code := :new.field3;
recLatestRead.trouble_code := :new.trouble_code;
recLatestRead.audit_code := :new.audit_code;
recLatestRead.processed := :new.processed;
recLatestRead.last_read_time := :new.field5;
recLatestRead.xcoord := :new.xcoord;
recLatestRead.ycoord := :new.ycoord;
recLatestRead.prev_read := :new.prev_read;
recLatestRead.notes := :new.notes;
recLatestRead.crew_type := :new.crew_type;


END trlast_amr_reading;
/
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 22 2010
Added on Jun 24 2010
5 comments
629 views