A stored procedure is a set of PL/SQL statements you can call by name. Procedure never returns a value to the environment in which it is called.
CREATE [OR REPLACE] PROCEDURE procedure_name (parameter_list) IS [Declaration Section] BEGIN [Executable Section] [EXCEPTION] [Exception Handling Section] END;
CREATE OR REPLACE PROCEDURE view_records ( tname IN VARCHAR2 ) IS a NUMBER; BEGIN EXECUTE IMMEDIATE 'SELECT COUNT(*) FROM '|| tname INTO a; DBMS_OUTPUT.PUT_LINE('TOTAL RECORDS '||a); END VIEW_RECORDS;
Call a procedure
BEGIN view_records('expenses'); END;