Evan Cutler
asked on
Dynamic SQL for ORACLE
Greetings EE Gods...
I am in need of some SQL help:
I have a list of indicator columns spread throughout 47 tables...
I can find them using the below select statement:
select 'select distinct ' || COLUMN_NAME || ' from ' || TABLE_NAME ||';' from ALL_TAB_COLUMNS where COLUMN_NAME ='ATCHMNT_IND' and OWNER = 'AABASE';
now, this gives me a recordset output that gives me a list of select queries to run.
What I need is to have them all run consecutively where a single output recordset can be achieved without adding tables to the schema.
Here's the output I'm looking for:
TABLE_NAME COLUMN_NAME VALUE
TABLE1 IND1 YES
TABLE1 IND1 No
TABLE1 IND1 3
TABLE1 IND2 J
TABLE1 IND2 No
TABLE2 IND1 12
etc...
Thanks
I am in need of some SQL help:
I have a list of indicator columns spread throughout 47 tables...
I can find them using the below select statement:
select 'select distinct ' || COLUMN_NAME || ' from ' || TABLE_NAME ||';' from ALL_TAB_COLUMNS where COLUMN_NAME ='ATCHMNT_IND' and OWNER = 'AABASE';
now, this gives me a recordset output that gives me a list of select queries to run.
What I need is to have them all run consecutively where a single output recordset can be achieved without adding tables to the schema.
Here's the output I'm looking for:
TABLE_NAME COLUMN_NAME VALUE
TABLE1 IND1 YES
TABLE1 IND1 No
TABLE1 IND1 3
TABLE1 IND2 J
TABLE1 IND2 No
TABLE2 IND1 12
etc...
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
xmltable is a function that allows you to query an xmltype value as if it were a table or view.
dbms_xmlgen executes the query you are generating to create the xmltype value.
dbms_xmlgen executes the query you are generating to create the xmltype value.
ASKER
what is XMLTABLE?????
and why is it used here?