Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a Java webapp with an Oracle DB, and I try to execute this statement at the end of a data migration script:

EXEC DBMS_STATS.GATHER_TABLE_STATS (ownname => 'MY_SCHEMA', tabname => 'MY_TABLE', estimate_percent => dbms_stats.auto_sample_size);

It works in sql*plus, but not via JDBC:

"Error: ORA-00900: invalid SQL statement"

What am I doing wrong?

share|improve this question

migrated from Sep 12 '13 at 12:33

This question came from our site for system and network administrators.

EXEC (EXECUTE) is a SQL*Plus native command (just like SHUTDOWN, HELP, SET, etc.), and not a part of SQL itself. – kubanczyk Sep 29 '13 at 21:43
up vote 4 down vote accepted

Instead of EXEC, you should put it between begin ... end, or use the { call } syntax. Here is an example, in the documentation:

share|improve this answer
Thanks, that did the trick. – Buddy Casino Sep 10 '13 at 17:17
CallableStatement cs = connection.prepareCall("{call MYPROCEDURE }");
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.