Monday, June 04, 2007

How to use GET_THRESHOLD

The day before yesterday, due to time issuing on solve production problem (as I am not faimiliar with PL/SQL). I didn't know to use DBMS_SERVER_ALERT.GET_THRESHOLD. Now I have the answer.

Thanks the article from http://turner.itpub.net/post/2343/66558

Below is sample to get threshold of tablespace used.

-- using DBMS_SERVER_ALERT.GET_THRESHOLD
variable warn_oper varchar2;
variable warn_value number;
variable crit_oper varchar2;
variable crit_value number;
variable obs_per number;
variable cons_oc number;

BEGIN
DBMS_SERVER_ALERT.GET_THRESHOLD(
DBMS_SERVER_ALERT.TABLESPACE_PCT_FULL,
:warn_oper, :warn_value, :crit_oper, :crit_value,
:obs_per, :cons_oc, 'OCP',
DBMS_SERVER_ALERT.OBJECT_TYPE_TABLESPACE ,NULL
);
END;
/
print warn_value
print crit_value


--to check specific tablespace is to replace NULL with actual name , like 'SYSTEM'

Things to notes are:

1. In the arguments, "=>" can't be used mixedly with traditional method. Otherwise you'll see PLS-00312: a positional parameter association may not follow a named association
2. Must GUESS the OBJECT_TYPE linked to metric name. Currently I don't this is well documented in ORACLE document sets.