Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Concatenating and copying columns data
Sounds like all you are trying to do is the following. This is just
pseudo code so you will have to verify that it actually operates
correctly on your end, but this should give you get you going in the
right direction. You will need to add some validation for column B.
It's typically bad practice to do this in a trigger, but if you have
to you should look at EXCEPTIONS(VALUE_ERROR).
CREATE TRIGGER YourTriggerName AFTER INSERT or UPDATE
BEGIN
UPDATE YourTableName A Set A.C = ASCII(A.A) + A.BWHERE A.ID =
new.ID;
END;
OR
CREATE TRIGGER YourTriggerName AFTER INSERT or UPDATE
BEGIN
/*Check to see if column B can be be cast to a numeric. If so update
column C. If not throw an exception.
UPDATE YourTableName A Set A.C = ASCII(A.A) + TO_CHAR(TO_ NUMBER(A.B)) WHERE A.ID = new.ID;
EXCEPTIONS
WHEN VALUE_ERROR //Do Something