Order of declaration in an anonymous pl/sql block

Posted by RenderIn on Stack Overflow See other posts from Stack Overflow or by RenderIn
Published on 2010-06-09T14:54:27Z Indexed on 2010/06/09 15:02 UTC
Read the original article Hit count: 169

Filed under:
|

I have an anonymous pl/sql block with a procedure declared inside of it as well as a cursor. If I declare the procedure before the cursor it fails. Is there a requirement that cursors be declared prior to procedures?

What other rules are there for order of declaration in a pl/sql block?

This works:

DECLARE
 cursor cur is select 1 from dual;
 procedure foo as begin null; end foo;
BEGIN
 null;
END;

This fails with error PLS-00103: Encountered the symbol "CURSOR" when expecting one of the following: begin function package pragma procedure form

DECLARE
 procedure foo as begin null; end foo;
 cursor cur is select 1 from dual;
BEGIN
 null;
END;

© Stack Overflow or respective owner

Related posts about Oracle

Related posts about plsql