我同意。语法图明确指出plsql_block
是有效地item_list_2
前面有一个可选的item_list_1
.
进一步,光标定义(与is
位)只能出现在item_list_2
和变量声明(带或不带=
)是其中的一部分item_declaration
设置,因此只能在item_list_1
.
这些事实使您的代码示例不正确,因此,如果它成功编译,则:
- 语法图是错误的;或者
- 编译器没有严格遵循它们;或者
- 您查看的代码涵盖了不同的语法图。
有趣的是,关于最后一个要点,11.1 的语法图 http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28370/block.htm#i32791略有不同。
声明部分可以是item_list_1
or item_list_2
or item_list_1
其次是item_list_2
.
有趣的是item_list_1
可以有任意数量的item_declaration
条目,这包括variable_declaration
and cursor_declaration
.
在 11.1 中,cursor_declaration
可以是一个声明or基于 11.2 中的语言元素的定义(换句话说,没有cursor_definition
类型,因为声明允许两者都在声明中)。
所以你所拥有的在 11.1 中是完全有效的,所以我要检查的第一件事是你实际上是running11.2 成功编译的地方。
It's still possible of course that you're running 11.2 and the syntax diagrams are wrong, in which case you should complain bitterly to Oracle but I don't know what sort of a response you'll get from a company whose flagship database product can't tell the difference between an empty varchar
and a NULL (a).
(a) I'll never pass up an opportunity to mention this and advance the cause of my beloved DB2 :-)