1
I was able to assemble the result, now missing create the view with this result. Which is the best way?
This consultation:
"SELECT CONCAT(CONCAT(CONCAT('SELECT * FROM ',a.OWNER),'.TAB2'),CASE WHEN a.OWNER = UPPER(b.TESTE1) THEN '' ELSE ' UNION ALL' END) TESTE
FROM ALL_TABLES a LEFT JOIN (SELECT MAX(b.DB_NAME) TESTE1 FROM INST.TAB1 b ORDER BY b.DB_NAME) b ON a.OWNER = UPPER(b.TESTE1)
WHERE a.TABLE_NAME = 'TAB2' AND a.OWNER IN(SELECT UPPER(c.DB_NAME) FROM INST.TAB1 c WHERE c.COL2 = 'Y' GROUP BY c.DB_NAME)
ORDER BY a.OWNER"
Give me this result:
SELECT * FROM INST1.TAB2 UNION ALL
SELECT * FROM INST1.TAB2 UNION ALL
SELECT * FROM INST1.TAB2 UNION ALL
SELECT * FROM INST1.TAB2 UNION ALL
SELECT * FROM INST1.TAB2 UNION ALL
SELECT * FROM INST1.TAB2 UNION ALL
SELECT * FROM INST1.TAB2
And now, you have how to execute this result and create a view so that you get both the result and the permanent view? What is the best way? Grateful.
The last painting is not the same as the second?
– Jéf Bueno
The second frame is 3 tables, Project1, Project2, Project3.
– user26858
Dude, this is confusing... what is the relationship between table and project table? Edit your question to make it more concise.
– Lucas Fontes Gaspareto
If you want to mount a query from the result of the first query you will have to do with PL/SQL, using a maybe Procedure. In my opinion the best way to do this is with Join.
– Lucas Fontes Gaspareto
a view with Union select coluna1,column2... from owner1.Tabela1 Union select coluna1,column2... from owner2.Tabela1 .... not being this to read way Enerica mount a sql and use a EXECUTE IMMEDIATE but the question became unclear , at least for me.
– Motta