Oracle PL/SQL/Stored Procedure Function/Procedure Function Body — различия между версиями

Материал из SQL эксперт
Перейти к: навигация, поиск
м (1 версия)
 
(нет различий)

Версия 13:45, 26 мая 2010

The syntax of calling subprograms with no parameters.

    
SQL>
SQL> CREATE OR REPLACE PROCEDURE NoParamsP AS
  2   BEGIN
  3     DBMS_OUTPUT.PUT_LINE("No Parameters!");
  4   END NoParamsP;
  5   /
Procedure created.
SQL>
SQL> show errors
No errors.
SQL>
SQL> CREATE OR REPLACE FUNCTION NoParamsF
  2     RETURN DATE AS
  3   BEGIN
  4     RETURN SYSDATE;
  5   END NoParamsF;
  6   /
Function created.
SQL>
SQL>
SQL> show errors
No errors.
SQL>
SQL> BEGIN
  2     NoParamsP;
  3     DBMS_OUTPUT.PUT_LINE("Calling NoParamsF on " || TO_CHAR(NoParamsF, "DD-MON-YYYY"));
  4   END;
  5   /
No Parameters!
Calling NoParamsF on 27-OCT-2009
PL/SQL procedure successfully completed.
SQL>
SQL>
SQL>



Use table column type as an variable type

  
SQL>
SQL>
SQL>  create table bar ( n number );
Table created.
SQL>
SQL>  create or replace procedure foo as
  2      l_n bar.n%type;
  3    begin
  4      null;
  5    end foo;
  6    /
Procedure created.
SQL>
SQL> EXEC foo();
PL/SQL procedure successfully completed.
SQL>
SQL> drop table bar;
Table dropped.
SQL>