I want to generate a view through php for an oracle database where the select is done through the result of another query.
This query mounts the select to the view:
$sql1 = "SELECT TESTE FROM VIEW_TESTE";
$result1 = odbc_exec($conOraSql , $sql1);
while ($row1 = odbc_fetch_array($result1)) {
$arrData[] = $row1["TESTE"]."<br />";
}
$select = implode('',$arrData);
The result of this query:
SELECT 'VAL1' COL1, 'VAL2' COL2, 'VAL3' COL3, 'VAL4' COL4, 'VAL5' COL5, 'VAL6' COL6, 'VAL7' COL7, 'VAL8' COL8 FROM VIEW TABELA1
UNION ALL
SELECT 'VAL1' COL1, 'VAL2' COL2, 'VAL3' COL3, 'VAL4' COL4, 'VAL5' COL5, 'VAL6' COL6, 'VAL7' COL7, 'VAL8' COL8 FROM VIEW TABELA2
UNION ALL
SELECT 'VAL1' COL1, 'VAL2' COL2, 'VAL3' COL3, 'VAL4' COL4, 'VAL5' COL5, 'VAL6' COL6, 'VAL7' COL7, 'VAL8' COL8 FROM VIEW TABELA3
And with this result, I wanted to mount a view this way, but without success, any tips?
$sql2 = "CREATE OR REPLACE FORCE VIEW \"USUARIO\".\"VIEW_TESTE2\" (\"COL1\", \"COL2\", \"COL3\", \"COL4\", \"COL5\", \"COL6\", \"COL7\", \"COL8\") AS $select";
$result2 = odbc_exec($conOraSql , $sql2);