【问题标题】:Oracle PLSQL, select in DBMS_STATS.GATHER_SCHEMA_STATSOracle PLSQL,在 DBMS_STATS.GATHER_SCHEMA_STATS 中选择
【发布时间】:2020-03-16 11:01:32
【问题描述】:

我想在 DBMS_STATS.GATHER_SCHEMA_STATS 中使用选择查询,但我写的代码返回错误。

EXECUTE DBMS_STATS.GATHER_SCHEMA_STATS((select sys_context( 'userenv','current_schema') from dual));

查询:select sys_context('userenv','current_schema') from dual;返回架构名称。

这是我的错误:

Error starting at line : 1 in command -
BEGIN DBMS_STATS.GATHER_SCHEMA_STATS((select sys_context( 'userenv','current_schema') from dual)); END;
Error report -
ORA-06550: line 1, column 39:
PLS-00103: Encountered the symbol "SELECT" 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
   <alternatywnie oznaczany literał napisowy ze specyfikacją zestawu znaków>
   <alternatywn
ORA-06550: line 1, column 96:
PLS-00103: Encountered the symbol ")" when expecting one of the following:

   . , @ ; for <an identifier>
   <a double-quoted delimited-identifier> group having intersect
   minus order partition start subpartition union where connect

06550. 00000 -  "line %s, column %s:\n%s"
*Cause:    Usually a PL/SQL compilation error.
*Action:

【问题讨论】:

  • 为什么不DBMS_STATS.GATHER_SCHEMA_STATS(USER);

标签: oracle plsql oracle11g


【解决方案1】:

你离得太近了。不用SELECT .. FROM DUAL

使用以下代码:

EXECUTE DBMS_STATS.GATHER_SCHEMA_STATS(sys_context( 'userenv','current_schema'));

干杯!!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-04-02
    • 1970-01-01
    • 2012-02-26
    • 2021-05-19
    • 1970-01-01
    • 2019-11-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多