PL / SQL执行完成并发出警告?

时间:2012-03-25 13:14:22

标签: oracle plsql

我在单独的页面中输入以下代码,它表示无效的程序名称。当在SQL Developer中的同一工作空间中一起键入时,它表示执行已完成并带有警告。似乎根本没有输出。

这是一项大学练习,使用用户输入的一个值从多个表中获取多个值 - 在本例中为ono

在这里,我们应该使用订单号(ono)获取图书的标题,订购数量和客户名称。

这是我的代码:

create or replace procedure proc2 ( ono in number
                    , cname out varchar, book out varchar, qty out number) is
   temp number;
begin    
   select custid into temp from ordr where orderno = ono;
   select custname into cname from customer where custid = temp;
   select isbn,qtystock into temp,qty from order_list where orderno = ono;
   select title into book from books where isbn = temp;
end proc2;

和我的主要调用函数:

set serveroutput on
declare
   cname varchar(7);
   book varchar(7);
   ono number;
   qty number;
begin
   ono := &ono; -- I even tried explicitly giving a value didn't work
   proc2(ono, cname, book, qty);
   dbms_output.put_line('customer name: '||cname||'book title :'||book||'quantity ordered   :'||qty);
end;

程序执行成功,但我似乎无法在主函数中找到错误。你觉得怎么回事?

即使我执行了以下操作,我也成功执行了函数,当我执行main函数时,我会被警告执行,我不明白为什么!

功能:

create or replace function totfun(ip in number) return number is
t number(5);
t1 number(5);
t2 number(5);
begin
select isbn,qtystock into t,t1 from order_list where orderno=ip;
select price into t2 from books where isbn=t;
return t1*t2;
end totfun;

主要功能:

set serveroutput on;
declare
ip number;
begin
ip:=&orderno;
dbms_output.put_line(totfun(ip));
end;

1 个答案:

答案 0 :(得分:1)

从手册:

  

在退出子程序之前,为所有OUT正式分配值   参数。否则,相应的实际参数将是   空值。如果成功退出,PL / SQL会将值分配给实际值   参数。如果退出时出现未处理的异常,则PL / SQL不会   为实际参数赋值。

您是否为输出参数指定了值?

退出proc2之前,您的输出参数是什么?

在程序proc2中跟踪代码是否有用?

你有什么警告?

Warnings: useful to read(link)

相关问题