Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

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:

Use the following code:

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

Cheers!!

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.