2011-12-25 18 views
0

嘿,我建立這個存儲過程:變量不能SQL語句之外使用

 CREATE OR REPLACE procedure fillCompanyWH 
     IS 
     cursor c is select other_line_key from line_contact; 
     cursor e is select max(comp_id) + 1 from Company_WH; 
     r c%ROWTYPE; 
     count PLS_INTEGER:=0; 
     rr NUMBER(9); 
     BEGIN 
       open c; 
       open e; 
        fetch e into rr; 
        if(rr is null) THEN 
         rr:=1; 
        end if; 
       count:= rr; 
       loop  
        count :=count + 1;    
       fetch c into r; 
       exit when c%NOTFOUND; 
         insert into Company_WH (comp_id, comp_key) values (count,r.other_line_key); 
       end loop; 

        close c; 
        close e; 
     END; 
     /

它不斷給我說說這行的錯誤(計數:= COUNT + 1) 錯誤說(語句被忽略的函數或僞列'COUNT'只能在SQL語句中使用)。

爲什麼?

回答

2

COUNT是內置功能。嘗試重命名你的變量。

+0

非常感謝我不知道:) – Lisa 2011-12-25 00:32:33

4

COUNT是一個保留字,因此您不能將它用於您的變量標識符。把它改成別的東西。