How to give an EXECUTE IMMEDIATE command in an ORACLE database from a JAVA application?

Question:

The error is when I run:

execute immediate 'update teste set num = 1234 where num = 1';

Exception:

java.sql.SQLSyntaxErrorException: ORA-00900: instrução SQL inválida

Answer:

You should only use the update command.

update teste set num = 1234 where num = 1

EXECUTE IMMEDIATE is only for executing SQL sentences inside PL/SQL function blocks or triggers (see documentation)

Scroll to Top