带参数存储过程的小例子

开始

CREATE OR REPLACE PROCEDURE query_emp

(p_id IN emp.empno%TYPE,

 p_name OUT emp.ename%TYPE,

 p_salary OUT emp.sal%TYPE)

IS

BEGIN

   SELECT ename,sal

   INTO p_name,p_salary

   FROM  emp

   WHERE empno = p_id;

END query_emp;

 生成完毕后,可以这样来执行:

DECLARE

  g_name varchar2(20);

  g_salary NUMBER(4);



BEGIN



  query_emp(7369,g_name,g_salary);

  

  DBMS_OUTPUT.put_line(g_name);

  DBMS_OUTPUT.put_line(g_salary);  



END;

结束

你可能感兴趣的:(存储过程)