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.