Procedures (Cont.)


Following the arguments is the keyword AS (IS is a synonym). Then comes the body, which is essentially a PL/SQL block. We have repeated the name of the procedure after the END, but this is optional. However, the DECLARE section should not start with the keyword DECLARE. Rather, following AS we have:
   ... AS
   <local_var_declarations>
   BEGIN
       <procedure_body>
   END;
   /
The slash / at the end runs the statement that creates the procedure; it does not execute the procedure. To execute the procedure, use another PL/SQL statement, in which the procedure is invoked as an executable statement. For example:
   BEGIN  addtuple1( 99 );  END;
   /
Question: The following procedure also inserts a tuple into T2, but it takes both components as arguments. After creation, add a tuple (10, 'abc') to T2.

 SQL> CREATE PROCEDURE  addtuple2( x T2.a%type,  y T2.b%type )  AS
   2  BEGIN
   3    INSERT INTO  T2( a, b )  VALUES( x, y );
   4  END  addtuple2;
   5  /
 Procedure created.

 SQL> BEGIN  addtuple2( 10, 'abc' );  END;
   2  /
 PL/SQL procedure successfully completed.




      It will be a cold day in Hell (not in a million years)    
      when I let you borrow my car!