Home » SQL & PL/SQL » SQL & PL/SQL » DBMS_SQL.PARSE for Oracle 7.3.4
DBMS_SQL.PARSE for Oracle 7.3.4 [message #36486] Thu, 29 November 2001 09:29 Go to next message
Dan
Messages: 61
Registered: February 2000
Member
I am trying to dynamically create a SQL select statement to retrieve only one piece of data (a sum). Is there an easy way for me to do this? My reason for doing this dynamically (or at least attempting to do so) is because I have 6 fields-- Q1, Q2, Q3, etc... and I'd like to be able to call a function and just pass in the number so I can do the SQL statement against the column based on the value coming in. ie.
SELECT SUM(X)
FROM TABLE
WHERE 'COL' = INPUT VARIABLE

with col being determined in the beginning of the function.

Any ideas??

----------------------------------------------------------------------
Re: Execute Immediate [message #36500 is a reply to message #36486] Fri, 30 November 2001 06:06 Go to previous message
SAlapati
Messages: 12
Registered: November 2001
Junior Member
In Oracle 8i, the EXECUTE IMMEDIATE statement prepares (parses)
and immediately executes a dynamic SQL statement
or an anonymous PL/SQL block.

The syntax is

EXECUTE IMMEDIATE dynamic_string
[[INTO {define_variable[[, define_variable]]... | record}]]
[[USING [[IN | OUT | IN OUT]] bind_argument
[[, [[IN | OUT | IN OUT]] bind_argument]]...]];

For more info
http://oradoc.photo.net/ora81/DOC/server.815/a67842/10_dynam.htm#8074

----------------------------------------------------------------------
Previous Topic: Re: Raise _application_error
Next Topic: insert using a view
Goto Forum:
  


Current Time: Thu Mar 28 11:54:18 CDT 2024