2012-03-25 47 views
3

我在單獨的頁面中輸入了下面的代碼,它表示無效的過程名稱。當在SQL Developer中的同一個工作空間中鍵入時,它表示執行完成並出現警告。似乎根本沒有產出。PL/SQL執行完成並出現警告?

這是一所大學的運動,從使用用戶輸入一個值幾個表得到幾個值 - 在這種情況下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; 

的過程已成功執行,但我似乎無法找到在主函數中的錯誤。你認爲什麼是錯的?

即使當我執行我得到函數執行成功,當我執行的主要功能我得到警告執行,我不明白爲什麼以下!

功能:

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; 
+3

使用'show errors'查看'CREATE ...'後面的編譯錯誤。您還應該閱讀多個'SELECT'語句。據我所知,只需一條語句「加入」表即可獲得相同的信息。 – 2012-03-25 13:25:48

+0

這是一個不錯的主意,我會嘗試;) – LoveMeow 2012-03-25 15:39:06

回答

1

從手冊:

退出子程序之前,將值分配給所有正式OUT參數 。否則,相應的實際參數將爲 爲空。如果您成功退出,PL/SQL將爲實際的 參數分配值。如果以未處理的異常退出,PL/SQL不爲 賦值給實際參數。

你已經賦值到您的輸出參數?

什麼是你的輸出參數之前從PROC2退出?

能追查過程PROC2裏面的代碼它是有用的?

你的警告是什麼?

Warnings: useful to read(link)