Posted on 2008-05-05 14:53
linlin yu 阅读(150)
评论(0) 编辑 收藏 所属分类:
oracle
create or replace procedure helloWorld AS
begin
DBMS_OUTPUT.PUT_LINE('HELLO.');
end;
运行
sql>set serveroutput on;
sql>exec
helloWorld ;
create or replace procedure MYPROC(ID NUMBER) IS
SURNAME VARCHAR2(30);
BEGIN
SELECT SURNAME INTO SURNAME FROM EMPLOYEE WHERE EMP_ID = ID;
DBMS_OUTPUT.put_line(SURNAME);
END;
CREATE OR REPLACE PROCEDURE MYPROC2(ID IN NUMBER, EMP_ID OUT NUMBER, SURNAME OUT VARCHAR2)
IS
BEGIN
SELECT EMP_ID, SURNAME INTO EMP_ID,SURNAME FROM EMPLOYEE WHERE EMP_ID=ID;
END;
运行
SQL> VARIABLE SURNAME VARCHAR2;
SQL> VARIABLE EMP_ID NUMBER;
SQL> EXEC MYPROC2(50,:EMP_ID,:SURNAME);