Requirement is to pass a variable with single quote as argument to Execute Immediate.I have tried the below code snippet so far..
how to get the code below working ??
declare
v_val varchar2(5);
v_match varchar2(5);
v_query VARCHAR2(500);
begin
v_val:='a''a';
  dbms_output.put_line(v_val);
v_val:=replace(v_val,'''','''''');
  dbms_output.put_line(v_val);
  v_query:='select val from test where val='||''''||v_val||''''||' and 1=1';                    
  execute immediate v_query into v_match;
  if(v_match=v_val) then
  dbms_output.put_line('match found');
  else
  dbms_output.put_line(' no match found');
end if;
  end;
In other words: I want to accept an input with apostrophe into substitution variable and then use that variable in a select statement's where clause to extract data from table.
i/p value : a'a select * from tabl where keyval=&inputval;
 
    