Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

how to display result of execute immediate on sql prompt

user451874Aug 14 2008 — edited Aug 18 2008
I wish to create a dynamic select statement where i will give table name and where condition as input parameters at runtime. for this i created following procedure:
CREATE or replace PROCEDURE select_rows (
table_name IN VARCHAR2,
condition IN VARCHAR2 DEFAULT NULL)
AS
where_clause VARCHAR2(100) := ' WHERE ' || condition;
BEGIN
IF condition IS NULL THEN where_clause := NULL; END IF;
EXECUTE IMMEDIATE 'select * FROM ' || table_name || where_clause;
END;

my procedure is successfully created.

my problem is how to get select stmt output at screen (sql prompt)
or how to spool the output in a file.
plz. help me. I am learning oracle .

thanx in adv.
Mani
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 15 2008
Added on Aug 14 2008
7 comments
11,237 views