如何在SQLPlus中运行PL / SQL代码?

时间:2009-08-20 13:02:31

标签: plsql sqlplus

我正在尝试在SQLPlus中运行以下代码:

exec lbacsys.sa_sysdba.create_policy(policy_name => 'ACCESS_LOCATIONS',
                                      column_name => 'OLS_COLUMN',
                                      default_options => 'READ_CONTROL,INSERT_CONTROL,UPDATE_CONTROL,DELETE_CONTROL,LABEL_DEFAULT,LABEL_UPDATE,CHECK_CONTROL,');

但是,我收到以下错误:

BEGIN lbacsys.sa_sysdba.create_policy(policy_name => 'ACCESS_LOCATIONS',; END;

                                                                        *
ERROR at line 1:
ORA-06550: line 1, column 78:
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

在我看来,我的语法错误。我只是不确定它是什么。任何帮助,将不胜感激。谢谢:))

1 个答案:

答案 0 :(得分:4)

EXEC语句采用一行代码并将其包装在BEGIN / END块中。在这种情况下,您希望将调用分成几行代码,因此您可能会发现自己添加BEGIN / END更容易:

BEGIN
  lbacsys.sa_sysdba.create_policy(policy_name => 'ACCESS_LOCATIONS',
                                  column_name => 'OLS_COLUMN',
                                  default_options =>
       'READ_CONTROL,INSERT_CONTROL,'
    || 'UPDATE_CONTROL,DELETE_CONTROL,'
    || 'LABEL_DEFAULT,LABEL_UPDATE,CHECK_CONTROL,');
END;
/