views:

107

answers:

1

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 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.

+8  A: 

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.

Tony Andrews
Excellent points! We will be talking with Oracle for clarification.
Adam Paynter
I suspect a level 1 analyst said "aha, DBMS_STANDARD isn't documented, and my handy dandy notebook tells customers not to use undocumented parameters or features without our guidance."
Adam Musch