sql - Oracle Procedure Escape characters -
i stuck escape characters give different values.please me solve problem.please me why same query giving different results.
query :
select * app_realm_entries id in (select id app_entries app_ext_code ='ttl1' , version_number='1.0.1');
result : single row result comes
sql block :
declare appcode varchar2(20); version_number varchar2(20); type rc ref cursor; table_cursor rc; rec_table realm_entries%rowtype; begin appcode := 'ttl1'; version_number := '1.0.1'; open table_cursor 'select * realm_entries id in (select id app_entries app_ext_code ='''||appcode||''||'and version_number='||version_number||''')'; loop fetch table_cursor rec_table; dbms_output.put_line('rowcount ' || table_cursor%rowcount ); exit when table_cursor%notfound; end loop; close table_cursor; end;
result : rowcount 0
as justin suggested use bind variables. you'll achieve 2 things doing that, won't need worry getting number of quotes correct, , more importantly, you'll close door sql injection vulnerabilities. can changing open statement following:
open table_cursor 'select * realm_entries id in (select id app_entries app_ext_code =:appcode , version_number=:version_number)' using appcode, version_number;
Comments
Post a Comment