oracle 存储过程 程序包。求纠错。。
发布网友
发布时间:2024-10-09 11:55
我来回答
共2个回答
热心网友
时间:2024-11-13 22:19
1、是正确的
create or replace package e_pa as
procedure p1(e_no emp.empno%type);
procedure p2(e_no emp.empno%type);
function f(e_no emp.empno%type) return date;
end e_pa;
2、小错误
--create or replace package e_pa body as
--这里写错了,应该是
create or replace package body e_pa as
procedure p1(e_no emp.empno%TYPE) as
e_name varchar2(20);
begin
select ename into e_name from emp where empno=e_no;
dbms_output.put_line(e_name);
end p1;
procedure p2(e_no emp.empno%type) as
e_sal varchar2(20);
begin
select sal into e_sal from emp where empno=e_no;
dbms_output.put_line(e_sal);
end p2;
function f(e_no emp.empno%type) return date as
e_date date;
begin
select hiredate into e_date from emp where empno=e_no;
return e_date;
end f;
end e_pa;
3、只有package body,没有对应的package
create or replace package body pa is
procedure updatetoyprice is
avgprice number;
begin
avgprice:=avgtoyprice;
while avgprice<=400 loop
update my_toys set price=(price*1.1) where (price*1.1)<=500;
avgprice:=avgtoyprice;
end loop;
end updatetoyprice;
function avgtoyprice return number is
vnum number;
begin
select avg(price) into vnum from my_toys;
return vnum;
end avgtoyprice;
end pa;
--创建package的sql如下
create or replace package pa as
procedure updatetoyprice;
function avgtoyprice return number;
end pa;
热心网友
时间:2024-11-13 22:24
也没点酬劳,和给精彩回答.难得看你的代码