Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How oracle dynamic sqls are handled in java programs?

957995Dec 27 2018 — edited Jan 2 2019

How oracle dynamic sqls are handled in java programs. I Have created a procedure and my procedure will receive a sql as a parameter and execute it using immediate execute. for example

create or replace procedure p_dynamicsql(p_query varchar2(500)) as

begin

execute immediate p_query;

processing ....;

end;

the procedure works fine and executes all the queries successfully in sqldeveloper. But now i am trying to call that procedure through java programs and passing the sqls inĀ  text box designed using html.

BUT JAVA is throwing errors. For example

begin

p_dynamicsql('select count(*) from emp where empnm = ''prema'' ');

end;

/

is working fine in database . But if I am passing 'select count(*) from emp where empnm = ''prema'' ' in a text box , java is throwing error that right parenthesis is missing. I am using jdbc to connect to oracle. Can any one explain how we can pass sqls with two single quotes for string variables to database by using java programs. I am using oracle 11g version.

This post has been answered by Zlatko Sirotic on Jan 2 2019
Jump to Answer
Comments
Post Details
Added on Dec 27 2018
14 comments
714 views