I have a query that involves multiple tables in Oracle, and returns a large number of columns. I wanted to instead of returning the records from this query, I would return the select columns as records.
An example of how more or less the current query is:
SELECT
tab1.campo1 'tab1.campo1',
tab1.campo2 'tab1.campo2',
tab1.campo3 'tab1.campo3',
tab2.campo1 'tab2.campo1',
tab2.campo2 'tab2.campo2',
tab2.campo3 'tab2.campo3',
tab3.campo1 'tab3.campo1',
tab3.campo2 'tab3.campo2',
tab3.campo3 'tab3.campo3',
tab4.campo1 'tab4.campo1',
tab4.campo2 'tab4.campo2',
tab4.campo3 'tab4.campo3'
FROM
tabela1 tab1,
tabela2 tab2,
tabela3 tab3,
tabela4 tab4
WHERE
tab1.campo2 = tab2.campo1
and tab2.campo3 = tab4.campo1
and tab1.campo3 = tab3.campo1
Again, I need to list these columns as rows.
I tried to use Unpivot, but without success.