1

I have a PHP calling Oracle database. The issue is that when I'm using SQLDeveloper to query the database with the given SQL, I can get the correct results. Now I have an existing PHP application that reads SQL from an XML. Other SQLs successfully returns rows, but when I used the given SQL it did not return any rows. Is there something wrong in my SQL which cannot be accepted in PHP Oracle? Or are there case where tables in Oracle that cannot be queried? Thank you.

SQL in XML file:

Select "PROJECT_NAME" From TABLE_A
Where EXISTS (                         
   SELECT "DATA ID", "DATA NAME" FROM TABLE_B
   WHERE  TABLE_B."DATA LEVEL" = 3
   AND TABLE_B."DATA TYPE" = 'TYPEA')
AND TABLE_A.COLUMN1 is null

PHP Code:

<?php 
echo '<br> sql: ' . $report_sql;
$stmt = oci_parse($conn, $report_sql);
oci_execute($stmt, OCI_DEFAULT);
echo '<div style="width:450px;"> <table id="tableBD1" class="display" cellspacing="0" width="100%">';
echo '<thead>
            <tr >
                <th>Project Name</th>
            </tr>
        </thead>';

echo '<tbody>';

while ($row=oci_fetch_array($stmt,OCI_BOTH)) 
{
  echo "<tr><td> <a href='#'>". $row['PROJECT_NAME'] . "</a> </td>";
}

echo '</tbody>';
echo '</table> </div>';

oci_free_statement($stmt);
?>
1
  • where is $report_sql? or is it exactly the same as the sql above? I think it could be syntax error Commented May 9, 2014 at 9:14

1 Answer 1

1

I think the problem may come from how you retrieve and handle your result row in PHP. Also I've faced similar issues using SDO_GEOMETRY with oracle in PHP.

I suggest you try to print your row before trying to print a specific field. It might be a good idea to make the request and it's treatment indepent. Sorry I don't have the reputation to only comment your question.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.