Home » SQL & PL/SQL » SQL & PL/SQL » Question on Cursor (Oracle 11g Windows)
icon5.gif  Question on Cursor [message #638105] Tue, 02 June 2015 06:17 Go to next message
brm2015
Messages: 1
Registered: June 2015
Junior Member
Hello All,

I have a requirement that have to execute one select statement inturn it provides list of select statements with columns and table names. I have to execute above output select statements as single select statement by unioning all the results. I was unable to combine those select statements into single query and not able to execute. Could you please help out in this regard.

Main SQL select 'select' ||column1||','||column2|| 'from table_name' from table_name

Output will be as multiple select statements. I have to combine those sql statements into single statement and execute.

Thanks in advance. Please let me know if you need more information.

Thanks,
BRM
Re: Question on Cursor [message #638106 is a reply to message #638105] Tue, 02 June 2015 06:32 Go to previous messageGo to next message
Michel Cadot
Messages: 68647
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

This is not clear what you have and what you want.
It should be better you post an example: CREATE TABLE and INSERT statements and explain what you want with them.

Re: Question on Cursor [message #638108 is a reply to message #638105] Tue, 02 June 2015 06:42 Go to previous messageGo to next message
Lalit Kumar B
Messages: 3174
Registered: May 2013
Location: World Wide on the Web
Senior Member
Welcome to the forum!

Please read and follow the OraFAQ Forum Guide and How to use [code] tags, to enable us to help you.

And as Michel said, you need to post a test case.
Re: Question on Cursor [message #638110 is a reply to message #638108] Tue, 02 June 2015 07:30 Go to previous messageGo to next message
bugfox
Messages: 18
Registered: October 2010
Junior Member
My guess (11g and above):
select 'select '||listagg(column_name, ',') within group(order by column_id)||' from '||table_name
from user_tab_columns
group by table_name
Re: Question on Cursor [message #638111 is a reply to message #638110] Tue, 02 June 2015 08:06 Go to previous message
Michel Cadot
Messages: 68647
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

But "I have to combine those sql statements into single statement and execute." is still a mystery.

Previous Topic: SQL & xml
Next Topic: Create dummy records using Model clause with condition for date field
Goto Forum:
  


Current Time: Fri Apr 26 13:37:20 CDT 2024