PHP ORACLE VIEW FROM SELECT

0

I want to generate a view through a select with the code below, but it does not work, what can it be?

$row[0] contains "select col1, col2, col3, col4, col5 from tabela1"

$select= oci_parse($ora_conexao, 'SELECT * FROM TABELA');
oci_execute($select);
while (($qrow = oci_fetch_row($select)) != false) {
    $arrData[] = $row[0].'<br />';
}
$var = implode('',$arrData);
//--> cria temp view
$view = oci_parse($ora_conexao,"CREATE OR REPLACE FORCE VIEW \"TD_ADMIN\".\"view1\" (\"col1\", \"col2\", \"col3\", \"col4\",  \"col5\") AS $var");
oci_execute($view);
    
asked by anonymous 14.01.2016 / 17:39

1 answer

1

I discovered the error by removing the line break here: $ arrData [] = $ row [0]. '' ';

stayed like this and working:

Bank connection:

//--> conexao oracle
//--> usuario
$ora_user = "ora_user"; 
//--> senha
$ora_senha = "ora_senha"; 
//--> caminho
$ora_bd = "(DESCRIPTION=
          (ADDRESS_LIST=
            (ADDRESS=(PROTOCOL=TCP) 
              (HOST=192.168.1.100)(PORT=1521)
            )
          )
          (CONNECT_DATA=(SERVICE_NAME=SERVICE_TESTE))
     )"; 
//--> monta a conexao
if ($ora_conexao = oci_connect($ora_user,$ora_senha, $ora_bd, 'AL32UTF8')){
    echo 'Conexão bem sucedida';
}else{
    echo 'Conexão falhada';
}

create oracle database select view:

$select= oci_parse($ora_conexao, 'SELECT * FROM TABELA');
oci_execute($select);
while (($qrow = oci_fetch_row($select)) != false) {
    $arrData[] = $row[0];
}
$var = implode('',$arrData);
//--> cria temp view
$view = oci_parse($ora_conexao,"CREATE OR REPLACE FORCE VIEW \"TD_ADMIN\".\"view1\" (\"col1\", \"col2\", \"col3\", \"col4\",  \"col5\") AS $var");
oci_execute($view);
    
14.01.2016 / 18:35