我有一個匿名的pl/sql塊,其中聲明瞭一個過程以及一個遊標。如果我在遊標之前聲明過程,它會失敗。是否有要求在程序之前聲明遊標?聲明在匿名pl/sql塊中的順序
對於pl/sql塊中的聲明順序,還有哪些其他規則?
這工作:
DECLARE
cursor cur is select 1 from dual;
procedure foo as begin null; end foo;
BEGIN
null;
END;
這種失敗,錯誤PLS-00103: Encountered the symbol "CURSOR" when expecting one of the following: begin function package pragma procedure form
DECLARE
procedure foo as begin null; end foo;
cursor cur is select 1 from dual;
BEGIN
null;
END;
文檔引用這裏 http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28370/block.htm#i32791 它不是很清楚,但「項目聲明」(如變量)在列表中1並且必須在「程序/函數定義」之前出現ich在列表2中。 – 2010-06-09 23:17:06
@Gary:非常好,謝謝! – 2010-06-10 14:51:50