CRISTIANO_CORRADI
asked on
A UNIQUE TRIGGER ON TWO COLUMNS - ORACLE PL/SQL PROGRAMMING
Good evening!
In a table called NEREPSTA_CONFIG, I have a column called REPSTA_SFTP_PASSWORD (type VARCHAR2), on which I've built the following trigger:
CREATE OR REPLACE TRIGGER MASTER.REPSTA_SOURCE
BEFORE INSERT OR UPDATE
OF REPSTA_SFTP_PASSWORD
ON MASTER.NEREPSTA_CONFIG
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
BEGIN
:NEW.repsta_sftp_password := cripta (:NEW.repsta_sftp_password );
END;
/
So, when a new record is inserted, on commit the NEREPSTA_SFTP_PASSWORD column is encrypted with che "CRIPTA" function. Moreover, when the field NEREPSTA_SFTP_PASSWORD is updated, on commit it's encrypted with the same "CRIPTA" function.
Now please suppose to ALTER the NEREPSTA_CONFIG table, adding a new column called NGNEER_SFTP_PASSWORD: I would like to modify the trigger in order to use the CRIPTA stored function ONLY on the field updated or inserted, not on both fields inconditionally: only the modified field has to be cripted with the CRIPTA function. Of course, if you INSERT a NEW record, both the fields NEREPSTA_SFTP_PASSWORD and NGNEER_SFTP_PASSWORD has to be crypted.
Any clues??
In a table called NEREPSTA_CONFIG, I have a column called REPSTA_SFTP_PASSWORD (type VARCHAR2), on which I've built the following trigger:
CREATE OR REPLACE TRIGGER MASTER.REPSTA_SOURCE
BEFORE INSERT OR UPDATE
OF REPSTA_SFTP_PASSWORD
ON MASTER.NEREPSTA_CONFIG
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
BEGIN
:NEW.repsta_sftp_password := cripta (:NEW.repsta_sftp_password
END;
/
So, when a new record is inserted, on commit the NEREPSTA_SFTP_PASSWORD column is encrypted with che "CRIPTA" function. Moreover, when the field NEREPSTA_SFTP_PASSWORD is updated, on commit it's encrypted with the same "CRIPTA" function.
Now please suppose to ALTER the NEREPSTA_CONFIG table, adding a new column called NGNEER_SFTP_PASSWORD: I would like to modify the trigger in order to use the CRIPTA stored function ONLY on the field updated or inserted, not on both fields inconditionally: only the modified field has to be cripted with the CRIPTA function. Of course, if you INSERT a NEW record, both the fields NEREPSTA_SFTP_PASSWORD and NGNEER_SFTP_PASSWORD has to be crypted.
Any clues??
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you very much for your fast, kind help ;-)
ASKER
500 points for you ;-)
Open in new window