简体   繁体   中英

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

I am calling a PL/SQL procedure like this:

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?

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

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

Update : Added link to documentation

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

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

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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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