Home » SQL & PL/SQL » SQL & PL/SQL » How to execute the result
How to execute the result [message #193679] Mon, 18 September 2006 23:55 Go to next message
mudalimuthu
Messages: 64
Registered: May 2005
Location: Bangalore
Member
Select
('Select '||(select column_name from user_tab_Columns
where table_name='PLDETAIL' and column_id = 7)||', '||(select column_name from user_tab_Columns
where table_name='PLDETAIL' and column_id = 12)||' From PLDetail') NewSQL
From Dual


From the above Query I got the following result
NewSQL
----------------------------------------------
Select DAYSWORKED, PFVALUE From PLDetail

I want to execute the result of that query

is it possible through sql
I dosnt want to use spool / @

thanking you
Re: How to execute the result [message #193692 is a reply to message #193679] Tue, 19 September 2006 00:39 Go to previous messageGo to next message
sandeepk7
Messages: 137
Registered: September 2006
Senior Member

Will it work for u?

Execute Immediate ('Select '||(select column_name from user_tab_Columns
where table_name='PLDETAIL' and column_id = 7)||', '||(select column_name from user_tab_Columns
where table_name='PLDETAIL' and column_id = 12)||' From PLDetail');


Sandy
Re: How to execute the result [message #193698 is a reply to message #193692] Tue, 19 September 2006 01:11 Go to previous messageGo to next message
mudalimuthu
Messages: 64
Registered: May 2005
Location: Bangalore
Member
Execute Immediate
IS NOT WORKING
Re: How to execute the result [message #193700 is a reply to message #193698] Tue, 19 September 2006 01:15 Go to previous messageGo to next message
sandeepk7
Messages: 137
Registered: September 2006
Senior Member

whats not working with Execute Immediate;

Execute Immediate ('Select '||(select column_name from user_tab_Columns
where table_name='PLDETAIL' and column_id = 7)||', '||(select column_name from user_tab_Columns
where table_name='PLDETAIL' and column_id = 12)||' From PLDetail') into your_variable;

You can access your desired o/p from your_variable.

Sandy
Re: How to execute the result [message #193882 is a reply to message #193700] Tue, 19 September 2006 15:50 Go to previous message
shoblock
Messages: 325
Registered: April 2004
Senior Member
1. that's NOT valid syntax for execute immmediate.
2. execute immediate is pl/sql. this is the sql forum, so if you're going to recommend pl/sql, you should mention that he'll need a begin/end
3. here's a sqlplus solution:
column newsql new_value new_sql

Select 
 (select column_name from user_tab_Columns
  where table_name='PLDETAIL' and column_id = 7)||
 ', '||
 (select column_name from user_tab_Columns
  where table_name='PLDETAIL' and column_id = 12)||
 ' From PLDetail' NewSQL
From Dual
/

select &new_sql
/

Previous Topic: horizontal data by column name
Next Topic: In vs Exists
Goto Forum:
  


Current Time: Sat Dec 03 01:15:26 CST 2016

Total time taken to generate the page: 0.13856 seconds