Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

ORA-00907: missing right parenthesis

user13814727Nov 7 2017 — edited Nov 8 2017

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

Comments

Processing
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Dec 6 2017
Added on Nov 7 2017
2 comments
362 views