Quantcast
Channel: Oracle, MySQL, Sybase, Informix and other databases
Viewing all articles
Browse latest Browse all 1350

Oracle dynamic SQL

$
0
0

hi there,

trying to do a simple sp which will take tablename, where condition, and fieldname , will return data into out parameter.

1) Please tell a way to do so.

2) Is it beneficial to write a SP for such calls? under what circumstances?, like i dont want other ppl to analyse my code and see what i am doing so i insist in coding SP's

create or replace
procedure getvalue
(
tblname in varchar2
, field in varchar2
, condition in varchar2
, val out varchar2
) as
begin
declare com varchar2(200);
com := '
BEGIN
SELECT :P1
INTO :P2
FROM :P3
WHERE :P4
END';
EXECUTE IMMEDIATE COM USING field,VAL,tblname,condition;
end getvalue;


Viewing all articles
Browse latest Browse all 1350

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>