Should procedures and/or functions of the DBMS_STANDARD package be used in PL/SQL code?
Recently, I encountered a BEFORE INSERT OR UPDATE
trigger on a table. In this trigger, the author relies on the INSERTING
and UPDATING
functions (both return a BOOLEAN
) of the DBMS_STANDARD
package to determine if the trigger was fired before an insert or before an update.
For example:
CREATE OR REPLACE TRIGGER CUSTOMER_TRIGGER
BEFORE INSERT OR UPDATE ON CUSTOMER
FOR EACH ROW
BEGIN
IF INSERTING THEN
/* Some code */
END IF;
IF UPDATING THEN
/* Some other code */
END IF;
END;
Yes, I know that two, individual triggers could have been written to handle the two events separately. That's not the point of this question.
After troubleshooting an error being received by these functions, we received word (from Oracle Support) that "dbms_standard routines 开发者_Go百科are not really meant to be called by user programs". Is this true?
I find this a little strange, considering other procedures (such as RAISE_APPLICATION_ERROR
and COMMIT
) are commonly used in PL/SQL code.
The functions INSERTING, UPDATING and DELETING are expressly provided for use in writing trigger code (see trigger documentation), so there is absolutely no proscription against using those. Similarly, RAISE_APPLICATION_ERROR is documented to be intended for use by developers.
Having just DESCribed DBMS_STANDARD there are certainly some functions in there I don't know about and that perhaps shouldn't be used in your own code (for all I know) such as GRANTEE.
Generally, if you can find Oracle official documentation telling you how to use something, then it is OK to use it.
精彩评论