I want to usue select query in DBMS_STATS.GATHER_SCHEMA_STATS but the code I wrote returns an error.
EXECUTE DBMS_STATS.GATHER_SCHEMA_STATS((select sys_context( 'userenv','current_schema') from dual));
The query: select sys_context( 'userenv','current_schema') from dual; returns the schema name.
And this is my error:
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);
– Wernfried Domscheit