我在尝试合并时遇到了这个错误:
PHP Warning: oci_execute(): ORA-01008: not all variables bound
我确保查询中的所有值都使用 oci_bind_by_name() 函数绑定,并且数据有效。
这是我的代码:
//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);
我正在使用 PHP 5 和 Oracle 10g。
有任何想法吗?