I'm trying to run a very simple Oracle procedure from PHP, using the following statement:
$sql = 'exec procedureName(param1, param2)';
$sql = oci_parse($connection, $sql); oci_execute($sql);
Running this in Oracle SQL developer returns a successful 'anonymous block completed' message, but running this via PHP returns an 'ORA-00900: invalid SQL statement' error.
Is there anyway to run this procedure from PHP? Many thanks
Looking a little deeper, I think you'll need to put your procedure call inside a PL/SQL BEGIN-END pair, as in:
$sql = 'BEGIN procedureName(:param1, :param2); END;';
$stmt_id = oci_parse($connection, $sql);
oci_bind_by_name($stmt_id, ':param1', $value1);
oci_bind_by_name($stmt_id, ':param2', $value2);
oci_execute($stmt_id);
You'll need to edit the above to use whatever variable names are appropriate in the calls to oci_bind_by_name
.
Also note that the presence of semi-colons in the SQL string is important.
Share and enjoy.