Select / Where with paramerto does not work in Oracle

0

I'm doing a select with where via PHP and Oracle, when you get an error with the parameter:

  

Warning: oci_execute (): ORA-00911: invalid character in C: \ xampp \ htdocs \ project \ includes \ Read.php on line 52   Warning: oci_fetch_array (): ORA-24374: define not done before fetch or execute and fetch in C: \ xampp \ htdocs \ project \ index.php on line

If I pass the direct parameter it works normally, as commented line, it works.

public function readAnexos($CDLICITACAO) {

    try{
        //$id = '012103';
        $id = $CDLICITACAO;

            $sql_query = "SELECT * FROM TBLICITCAO WHERE CDLICITACAO = $id";
            $stid = oci_parse($this->db, $sql_query);

            oci_execute($stid);
            return $stid;

        }

    catch (Exception $e){
        echo $e->getMessage() . "<br>Error na linha:  ";
        echo "<b>" . $e->getTraceAsString()."</b>";
        parent::fechar();
    }
}
    
asked by anonymous 13.04.2018 / 15:03

2 answers

0

The problem is in the identification of $id , is not passing the variable but rather the string '$id' to be compared with a probably integer field.

To solve your problem replace the query line with:

$sql_query = "SELECT * FROM TBLICITCAO WHERE CDLICITACAO = ".$id;
    
13.04.2018 / 15:15
0

It did not work, it generated an error ... but the sql is correct, if I run it in the database, it works.

  

string (80) "SELECT * FROM TBLICITCAO WHERE CDLICITACAO = 014384"

Warning: oci_execute (): ORA-00911: invalid character in C: \ xampp \ htdocs \ project \ includes \ Read.php on line 48

Warning: oci_fetch_array (): ORA-24374: define not done before fetch or execute and fetch in C: \ xampp \ htdocs \ project \ index.php on line 72

    
13.04.2018 / 15:20