注意:存储过程创建失败查看:PL/sql左侧浏览器选择Procedures,选中存储过程,右击view
/* 创建存储过程 */
-- 不带参数的存储过程create or replace procedure sayHelloWorld --sayHelloWorld为过程名
as
--declare
--变量说明
begin
dbms_output.put_line('Hello World');
end;
-- 调用存储过程
EXEC sayHelloWorld();
BEGIN
sayHello();
sayHello();
END
-- 带输入参数的存储过程
create or replace procedure raiseSalary(eno in NUMBER)
as
psal emp.sal%type;
begin
select sal into psal from emp where empno=eno;
update emp set sal=sal+100 where empno=eno;
dbms_output.put_line('涨前:'||psal||' 涨后:'||(psal+100));
end;
-- 带输入输出参数
CREATE OR REPLACE PROCEDURE queryEmpInfo(eno IN NUMBER,pename OUT VARCHAR2,psal OUT NUMBER,pjob OUT VARCHAR2)
AS
BEGIN
SELECT ename,sal,job INTO pename,psal,pjob FROM emp WHERE empno=eno;
dbms_output.put_line('姓名:'||pename||',工资;'||psal);
END;
-- PLsql终端执行
declare
eno number := &eno;
pename varchar2(80); psal number; pjob varchar2(80); begin queryEmpInfo(1001,pename,pjob); end; 原文链接:https://www.f2er.com/oracle/208080.html