Procedures (Cont.)


The following illustrates the use of an OUT parameter:

 SQL> CREATE TABLE  T3 (
   2    a  INTEGER,
   3    b  INTEGER );
 Table created.

 SQL> CREATE PROCEDURE  addtuple3( x NUMBER, y OUT NUMBER ) AS
   2  BEGIN
   3    y := 4;
   4    INSERT INTO  T3(a, b)  VALUES(x, y);
   5  END;
   6  /
 Procedure created.

 SQL> DECLARE
   2    v  NUMBER;
   3  BEGIN
   4    addtuple3(10, v);
   5  END;
   6  /
 PL/SQL procedure successfully completed.

The input argument for an
OUT or INOUT parameter should be something with an “lvalue,” such as a variable like v in the above. A constant or a literal argument should not be passed in for an OUT/INOUT parameter. To find out what procedures and functions you have created, use the following SQL:
 SELECT  object_type, object_name  FROM  user_objects
   WHERE object_type = 'PROCEDURE' OR object_type = 'FUNCTION';
To drop or describe a stored procedure/function:
   DROP  PROCEDURE/FUNCTION  <procedure_name>;
   DESC  <procedure/function_name>;
To view the text of a procedure/function (by using an uppercase-letter name):
   SELECT  text  FROM  user_source
     WHERE  type = 'PROCEDURE' AND name = 'PROCEDURE_NAME';