2011-08-24 2 views
1

의`declare` 섹션의 항목의 특정 순서를 필요합니까 "Is Oracle's syntax diagram for PL/SQL blocks wrong?는" René Nyffenegger 오라클이 에서 블록의 선언 섹션에 보다 선행 변수 선언에 커서 정의를 허용하는 방법을 보여 주었다 Oracle's documenation에도 불구하고 이 허용되지 않았습니다. 그가 무엇인가 놓치고 있는지 물었다.오라클의 PS/SQL 질문에서 블록

Paxdiablo's answer은 커서 정의가 커서 정의는 item_list_2에서 사용할 수 있으며 item_list_1이 item_list_2 전에 을 제공, 변수 선언하기 전에이 변수 선언 이후 만 item_list_1에서 허용되는 올 수없는 문서 의 르네의 읽기와 동의 .

René는 "item_1 요소와 item_2 요소 사이에 어떤 구별이 있는지 궁금합니다." 내 말에, "블록 신고 섹션에 다른 유형의 항목간에 어떤 주문이 필요합니까?"

답변

3

오라클 10g R2에서 대답은 예, 커서 정의가 허용되지 않는 경우에도 item_list_1과 item_list_2의 항목간에 순서가 지정되어야합니다 ( ).

는 예를 들어, 프로 시저 정의는 변수 선언하기 전에 허용되지 않습니다 :

SQL> select * from v$version; 

BANNER 
---------------------------------------------------------------- 
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi 
PL/SQL Release 10.2.0.4.0 - Production 
CORE 10.2.0.4.0 Production 
TNS for Solaris: Version 10.2.0.4.0 - Production 
NLSRTL Version 10.2.0.4.0 - Production 

SQL> declare 
    2  variable_declaration number; 
    3  procedure procedure_definition is begin 
    4   null; 
    5  end procedure_definition; 
    6 begin 
    7  null; 
    8 end; 
    9/

PL/SQL procedure successfully completed. 

SQL> declare 
    2  procedure procedure_definition is begin 
    3   null; 
    4  end procedure_definition; 
    5  variable_declaration number; 
    6 begin 
    7  null; 
    8 end; 
    9/
    variable_declaration number; 
    * 
ERROR at line 5: 
ORA-06550: line 5, column 5: 
PLS-00103: Encountered the symbol "VARIABLE_DECLARATION" when expecting one of the following: 
begin function package pragma procedure form 
ORA-06550: line 8, column 4: 
PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following: 
end not pragma final instantiable order overriding static 
member constructor map 
1

I 생각 (매우 제한된 empric 시험 기준) 그하지만 첫 번째 procedure definition 또는 function definItion 아무것도 후 더 procedure definitions 또는 function definitions이 허용됩니다.

그래서, variable declarations (또는 더 일반적으로 item declarations), cursor declarations, type definitions 등은 item 1 elems해야하고 (아마 단지) function definitionsprocedure definitionsitem 2 elems (만 item 2 elems)이어야한다.

function declarationsprocedure declarationsitem 1 elemsitem 2 elems 모두 허용됩니다 (또는있는 것처럼 보입니다).

+0

11gR2에 있었습니까? 나는 11gR2를 가지고 있지 않다. 당신이 묘사하는 것이 10g2의 행동 인 것으로 보인다. 나의 답안의 오류 메시지와 일치한다. 또한 10gR2 설명서에 설명 된 동작입니다. http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/block_declaration.htm#sthref2482 –

+0

예, 10gR2에있었습니다. 나는 월요일까지 11gR2를 만질 수 없을 것이다. –