繁体   English   中英

匿名pl / sql块中的声明顺序

[英]Order of declaration in an anonymous pl/sql block

我有一个匿名的pl / sql块,其中包含一个声明的过程以及一个游标。 如果我在光标之前声明该过程则失败。 是否要求在程序之前声明游标?

pl / sql块中的声明顺序还有哪些其他规则?

这有效:

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

这失败并出现错误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;

需要在包/函数之前声明游标,变量,常量和类型。

这个也会失败:

DECLARE
 procedure foo as begin null; end foo;
 x VARCHAR2(10);
BEGIN
 null;
END;

如果要声明子过程可用的游标,只需添加另一个匿名块:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM