I agree. The syntax diagrams explicitly state that plsql_block effectively item_list_2 , which is preceded by an optional item_list_1 .
In addition, cursor definitions (with the is bit) can only be found in item_list_2 , and variable declarations (with or without = ) are part of the item_declaration set and therefore can only be found in item_list_1 .
These facts make your code incorrect, so if it manages to compile, then either:
- The syntax diagrams are incorrect. or
- the compiler does not follow the letter; or
- your look at code that applies to various syntax diagrams.
At this last marker point, interestingly, the syntax diagrams for 11.1 are slightly different.
An ad section can be item_list_1 or item_list_2 or item_list_1 followed by item_list_2 .
Interestingly, item_list_1 can have any number of item_declaration entries, and this includes both variable_declaration and cursor_declaration .
In 11.1, a cursor_declaration can be either a declaration or a definition based on language elements in 11.2 (in other words, there is no type cursor_definition , because the declaration allows both in the declaration).
So, what you have is absolutely true in 11.1, so the first thing I will check is that you are actually executing 11.2 where this successful compilation takes place.
It’s still possible that you are using 11.2, and the syntax diagrams are wrong, in which case you should complain about Oracle, but I don’t know what answer you will get from a company whose flagship database product cannot tell the difference between an empty varchar and NULL (a) .
(a) I will never miss the opportunity to mention this and promote the cause of my beloved DB2 :-)