2014-03-31 31 views
-2

當我執行這個程序PL/SQL:語句ingored

create procedure p2 is 
     cursor c100 is select b.BNO,b.BNAME,b.PUBNAME,b.PRICE 
     from book b,author a, bo_aut ba 
     where b.BNO=ba.BNO 
     and a.ANO=ba.ANO 
     and a.ANAME='kanetkar'; 
    begin 
     for x in c100 
    loop 
     dbms_output.put_line(x.BNO||'  '||x.BNAME||'  '||x.PUBNAME||'  '||x.PRICE); 
    end loop; 
    end; 
/

得到這個錯誤

錯誤在第10行:PL/SQL:語句被忽略
1. CREATE PROCEDURE p2爲
2. cursor c100 is select b.BNO,b.BNAME,b.PUBNAME,b.PRICE
3. from book b,author a,bo_aut ba

+0

你可以發表你的表架構嗎? –

回答

1

您的SQL語句出錯(所以select ...部分)。

如果沒有模式,我們不能說出確切的原因,但嘗試運行查詢本身並找出問題所在。

+0

非常感謝你。是的,你是正確的,我在查詢中給出了錯誤的模式名稱,我只是糾正它,它運行良好。 – user2955696

0

遊標中的查詢必須有錯誤。我已經把一個基本的例子的等效方法,用工作查詢:

create or replace procedure p2 is 

    cursor c100 is 
     select 'a1' as BNO, 'b1' as BNAME, 'c1' as PUBNAME, 'd1' as PRICE 
     from dual 
     union 
     select 'a2' as BNO, 'b2' as BNAME, 'c2' as PUBNAME, 'd2' as PRICE 
     from dual; 

begin 
    for x in c100 loop 
     dbms_output.put_line(x.BNO||'  '||x.BNAME||'  '||x.PUBNAME||'  '||x.PRICE); 
    end loop; 
end; 

由此我得到預期的輸出:

a1  b1  c1  d1 
a2  b2  c2  d2 

我建議單獨運行您的SQL調試。