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

Asked

Viewed 474 times

3

The error is when I execute:

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

Exception:

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

    Hello @lucasRomero, welcome to [en.so]. In what context are you trying to perform this command? If it is via application, would not an update be enough? If my memory doesn’t fail me, execute immediate is to be used within triggers and functions

  • That line I posted is just for testing, the ones that will be run I don’t have access.

  • Renan, the part of the command update teste set num = 1234 where num = 1 is beautiful, I have tested select, Insert, update and delete. I did not run tests with execute immediate.

  • I removed my previous comment because it was really wrong according to the manual. The column num is really numerical?

  • It’s numerical. If I just run update teste set num = 1234 where num = 1 it works, the problem is when I add excute immediate.

1 answer

1


You should only use the update command

update teste set num = 1234 where num = 1

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.