oracle 在多行中中断 PL/SQL 过程调用的正确语法是什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4529665/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 22:17:25  来源:igfitidea点击:

What is the correct syntax to break a PL/SQL procedure call in multiple lines?

sqloracleplsqlsqlplusora-06550

提问by Moeb

I am calling a PL/SQL procedure like this:

我正在调用这样的 PL/SQL 过程:

execute util.verify(src_schema => '&username',
                    stab       => '&tab_name');

and I get these errors:

我收到这些错误:

SQL> execute util.verify(src_schema => '&username',
BEGIN util.verify(src_schema => 'u1',; END;

                                     *
ERROR at line 1:
ORA-06550: line 1, column 57: 
PLS-00103: Encountered the symbol ";" when expecting one of the following:
( - + case mod new not null <an identifier>
<a double-quoted delimited-identifier> <a bind variable>
continue avg count current exists max min prior sql stddev
sum variance execute forall merge time timestamp interval
date <a string literal with character set specification>
<a number> <a single-quoted SQL string> pipe
<an alternatively-quoted string literal with character set specification>
<an alternatively


SQL>                   stab       => '&tab_name',
SP2-0734: unknown command beginning "stab      ..." - rest of line ignored.

Looks like I cannot just break the call in between at a ,. How can I write this call in multiple lines?

看起来我不能只是在 a 之间中断呼叫,。如何在多行中编写此调用?

回答by Ronnis

In SQLPlus, you put a dash at the end of lines that continues on the next line.

在 SQLPlus 中,您在下一行继续的行尾放置一个破折号。

execute util.verify(src_schema => '&username', -
                    stab       => '&tab_name');

Update: Added link to documentation

更新:添加了文档链接

EXECUTE, SQL*Plus? User's Guide and Reference

执行,SQL*Plus?用户指南和参考

回答by bernd_k

There is an alternative way, some thing like the below:

有一种替代方法,如下所示:

begin
    util.verify(src_schema => '&username',
                    stab       => '&tab_name');
end;
/

回答by Codo

execute xxxx;(or exec xxxx;) is a short-cut for writing begin xxxx; end;

execute xxxx;(或exec xxxx;) 是写作的捷径begin xxxx; end;

It only works for one liners. So if you have multiple lines, you need to explicitly use beginand end.

它只适用于一个班轮。因此,如果您有多行,则需要明确使用beginand end