Hi!
I'm building a PHP script to pull data from a remote server. We're making the connection but the query is failing.
Here's the code:
<?php
$conn = oci_connect('abc', 'abcded', '192.168.0.7/abcd'); // Not the actual connect parameters.
if (!$conn) {
$e = oci_error();
trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
}
$stid = oci_parse($conn,"SELECT CAV_MBRSEPMSTR.SERVTYPE, IIF(CAV_MBRSEPMSTR.SERVTYPE = '01', 'INT', 'VOIP') AS SERVDESC, LEFT(CAV_MBRSEPMSTR.ACCTSTATUS,1) AS ACCTSTATUS, CAV_MBRSEPMSTR.MBRSEP,CAV_MBRSEPMSTR.NAME FROM CAV_MBRSEPMSTR WHERE VAL(SERVTYPE)<>0 AND LEFT(ACCTSTATUS,1) IN ('A','N')");
oci_execute($stid);
echo "<table border='1'>\n";
while ($row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS)) {
echo "<tr>\n";
foreach ($row as $item) {
echo " <td>" . ($item !== null ? htmlentities($item, ENT_QUOTES) : " ") . "</td>\n";
}
echo "</tr>\n";
}
echo "</table>\n";
?>
I get this output:
PHP Warning: oci_execute(): ORA-00907: missing right parenthesis in /home/oracleTest.php on line 37
<table border='1'>
PHP Warning: oci_fetch_array(): ORA-24374: define not done before fetch or execute and fetch in /home/oracleTest.php on line 41
</table>
when I run it in a terminal window. The script must run on this server and then feed the data to other processes that are local to the server. Those processes will be added to this script as soon as it starts returning the result of this query.
Some other queries that don't fail include:
$stid = oci_parse($conn, 'SELECT * FROM CAV_MBRSEPMSTR');
and
$stid = oci_parse($conn, 'SELECT CAV_MBRSEPINFODETL.MBRSEP,CAV_MBRSEPINFODETL.FAX,CAV_MBRSEPINFODETL.CELLPHONE,CAV_MBRSEPINFODETL.OTHERPHONE,CAV_MBRSEPINFODETL.EMAILADDR FROM CAV_MBRSEPINFODETL');
I know very little about Oracle; I'm used to MySQL. I suspect that the fault lies in this part ", IIF(CAV_MBRSEPMSTR.SERVTYPE = '01', 'INT', 'VOIP')" and probably also this part "WHERE VAL(SERVTYPE)<>0 AND LEFT(ACCTSTATUS,1) IN ('A','N')".
Any help would be greatly appreciated.
Thanks in advance,
Steve