I am encountering this errir when attempting to do a merge:
PHP Warning: oci_execute(): ORA-01008: not all variables bound
I’ve made sure that all values that I have in the query are bound using the oci_bind_by_name() function, and that the data is valid.
Here is my code:
//Sample values just to test
$col1val = 'test1';
$col2val = 'test2';
$col3val = 'test3';
$col4val = 'test4';
$sql = "merge into tablespace.tb1 c using (select :col1val from dual) cd
on (c.col1 = cd.col1)
when not matched then
insert (c.col2, c.col1, c.col3, c.col4)
values (:col2val, :col1val, :col3val, :col4val)";
oci_bind_by_name($stid, ":col1val", $col1val);
oci_bind_by_name($stid, ":col2val", $col2val);
oci_bind_by_name($stid, ":col3val", $col3val);
oci_bind_by_name($stid, ":col4val", $col4val);
$stid = oci_parse($conn, $sql);
$result = oci_execute($stid);
oci_free_statement($stid);
I am using PHP 5 and Oracle 10g.
Any ideas?
The problem was that
oci_bind_by_name()was being called beforeoci_parse().oci_parse()needs to be called first.