Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Dynamic SQL Reality Check
Hello,
In getting deeper with PL/SQL using Oracle 10g R2 I have a need to execute SQL statements that are not static. In wading through the internet common Oracle docs sites it seems I must use "Oracle Native Dynamic SQL".
Please tell me I am wrong. In comparison to the years of using SQL with other SQL engines this is like a real bad LCD trip ...R-E-A-L B-A-D. :-)
At the crux, I am using a package and have a function I wish to pass a completely dynamic (yet simple) SQL string where the only thing that is a constant is the table name.
A psuedo code example function specs:
FUNCTION qryTable (
vTable IN varchar2, vFields IN varchar2, vWhere IN varchar2
sSQL := 'SELECT ' || vFields || ' FROM ' || vTable || ' WHERE ' ||
vWhere ;
-- Create a cursor from sSQL next ...
What is the easiest way to do this that will work in the structure of a Package via a function call?
Thanks for your advice,
Michael Received on Sun Jan 14 2007 - 08:59:28 CST