Re: PL/SQL Interpreter oddity - bug or "expected"?

From: Toon Koppelaars <toon_at_rulegen.com>
Date: Sun, 18 Mar 2018 22:27:14 +0100
Message-ID: <CAA9w=EvKXVB7uVK7DmbZ=iR=ReTCh0KC3m1CJFo8NfZBXL-WfA_at_mail.gmail.com>



From "the man" himself:

blogs.oracle.com/plsql-and-ebr/reserved-words%2ckeywords %2c-and-the-ends-of-labeled-blocks

On Sat, Mar 17, 2018 at 6:13 AM, Stefan Knecht <knecht.stefan_at_gmail.com> wrote:

> Ran into this recently, and personally I feel that this should not
> compile. What do you guys think?
>
> Simple case in point:
>
> create or replace package foo as
> procedure bar;
> end;
> /
>
> Package created.
>
>
> create or replace package body foo as
> procedure bar
> is
> begin
> begin
> null;
> end loop;
> end;
> end;
> /
>
> Package body created.
>
> show errors
>
> No errors.
>
> SQL> exec foo.bar
>
> PL/SQL procedure successfully completed.
>
>
> What is happening is that Oracle interprets the "end loop" as being "end
> anonymous_block_name". And in my opinion, with a keyword like "loop" that
> should not be happening. In essence, the above is interpreted as:
>
> create or replace package body foo as
> procedure bar
> is
> begin
> begin
> null;
> end anon_block_name;
> end;
> end;
> /
>
>
> If we switch the "end loop" to an "end if" (which is a similar flow
> control keyword) it reacts (in my opinion) correctly:
>
> create or replace package body foo as
> procedure bar
> is
> begin
> begin
> null;
> end if;
> end;
> end;
> /
>
> Warning: Package Body created with compilation errors.
>
> SQL> show errors
> Errors for PACKAGE BODY FOO:
>
> LINE/COL ERROR
> -------- -----------------------------------------------------------------
> 7/7 PLS-00103: Encountered the symbol "IF" when expecting one of the
> following:
> ; <an identifier> <a double-quoted delimited-identifier>
> The symbol "IF" was ignored.
>
> SQL>
>
>
> Would you agree that that should not compile in the first place?
>
>
>
> Stefan
>
>
>
>
>
> --
> //
> zztat - The Next-Gen Oracle Performance Monitoring and Reaction Framework!
> Visit us at zztat.net | Support our Indiegogo campaign at igg.me/at/zztat
> | _at_zztat_oracle
>

-- 
Toon Koppelaars
RuleGen BV
Toon.Koppelaars_at_RuleGen.com
www.RuleGen.com
TheHelsinkiDeclaration.blogspot.com

(co)Author: "Applied Mathematics for Database Professionals"
www.RuleGen.com/pls/apex/f?p=14265:13

--
http://www.freelists.org/webpage/oracle-l
Received on Sun Mar 18 2018 - 22:27:14 CET

Original text of this message