Here's the scenario. I want to update a LAST_MODIFIED_DATE field in my table when only specifed fields are updated in a table and not others. So, of course, I use a trigger and I could easily hardcode each field in my trigger to something like:
IF :new.field1 <> ld.field1 THEN
SELECT sysdate
INTO :new.LAST_MODIFIED_DATE
FROM dual;
END IF;
IF :new.field2 <> ld.field2 THEN
SELECT sysdate
INTO :new.LAST_MODIFIED_DATE
FROM dual;
END IF;
Easy enough. Want I really want to do is to store each field name in a table, return a cursor containing the field names, and loop through the cursor instead of hardcoding each and every field separately. Is something like this possible?
IF :new.field1 <> ld.field1 THEN
SELECT sysdate
INTO :new.LAST_MODIFIED_DATE
FROM dual;
END IF;
IF :new.field2 <> ld.field2 THEN
SELECT sysdate
INTO :new.LAST_MODIFIED_DATE
FROM dual;
END IF;
Easy enough. Want I really want to do is to store each field name in a table, return a cursor containing the field names, and loop through the cursor instead of hardcoding each and every field separately. Is something like this possible?