Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6363407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:02:08+00:00 2026-05-25T00:02:08+00:00

I suspect that the syntax diagram for a plsql_block as given in the Oracle®

  • 0

I suspect that the syntax diagram for a plsql_block as given in the
Oracle® Database PL/SQL Language Reference for Relese 2 is wrong.
(For reference, here’s the current link to that document)

The following piece of PL/SQL compiles fine:

declare

  cursor 
    cursor_definition 
  is select * from dual;

  variable_declaration number;

begin
  null;
end;

The following statements are assumptions that I make based on the piece of PL/SQL above and based on Oracle’s syntax diagram.

  1. The declare section (above) consists of a cursor definition followed by a variable declaration (which in turn is an item declaration).

  2. An item declaration can only be an element of an item list 1.

  3. A cursor definition can only be an element of an item list 2.

  4. An item list 2 can never be followed by an item list 1.

Now, the variable declaration following the cursor definition contradicts point 4. Therefore I conclude that the
syntax diagram is wrong.

Maybe I am overlooking something, in which case I’d be very grateful for pointing this out to me.

Please understand that a wrong syntax diagram per se is no big deal to me. But I am in the process of writing a PL/SQL parser
and the parser stumbles for the exact situation given with the example PL/SQL code. So, in order to improve the parser, I’d like
to have a more authorative sequence diagram.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T00:02:09+00:00Added an answer on May 25, 2026 at 12:02 am

    I concur. The syntax diagrams explicitly state that a plsql_block is effectively item_list_2 preceded by an optional item_list_1.

    Further, cursor definitions (with the is bit) can only occur in item_list_2 and variable declarations (with or without an =) are part of the item_declaration set and can therefore only be in item_list_1.

    Those facts make your code sample incorrect so, if it manages to compile, then either:

    • the syntax diagrams are wrong; or
    • the compiler doesn’t follow them to the letter; or
    • your looking at code that’s covered by different syntax diagrams.

    On that last bullet point, interestingly enough, the syntax diagrams for 11.1 are slightly different.

    The declare section can be item_list_1 or item_list_2 or item_list_1 followed by item_list_2.

    Where it gets interesting is that 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 the language elements in 11.2 (in other words, there is no cursor_definition type since the declaration allows both in the declaration).

    So what you have is perfectly valid in 11.1 so the first thing I’d check is that you’re actually running 11.2 where that successful compilation is taking place.

    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 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.