PHP oci_execute():ORA-01008:并非所有变量都绑定

时间:2017-08-16 07:05:01

标签: php oracle

我试图将数据从php插入到oracle

但我有错误oci_execute(): ORA-01008: not all variables bound

注意:插入一些并非所有数据都列在表格中的数据。

$sql =  'INSERT INTO LIC_WEB_VIOLATIONS (VIO_CODE, LIC_CODE, LIC_NO , NOTES, PAID_FLAG, AUDIT_FLAG, TYPE, STATUS, LIC_TYPE, OWNER_ID, CREATION_DATE, CREATION_USER_ID) 
VALUES(:VIO_CODE, :LIC_CODE, :LIC_NO, :NOTES, :PAID_FLAG, :AUDIT_FLAG, :TYPE, :STATUS, :LIC_TYPE, :OWNER_ID, :CREATION_DATE , :CREATION_USER_ID)';

$stid = oci_parse($objConnect, $sql);

oci_bind_by_name($stid, ':VIO_CODE', $VioCode);
oci_bind_by_name($stid, ':LIC_CODE', $Lic_Code);
oci_bind_by_name($stid, ':LIC_NO', $Lic_no);
oci_bind_by_name($stid, ':NOTES', $NOTES);
oci_bind_by_name($stid, ':PAID_FLAG', $PAID_FLAG);
oci_bind_by_name($stid, ':AUDIT_FLAG', $AUDIT_FLAG);
oci_bind_by_name($stid, ':TYPE', $TYPE);
oci_bind_by_name($stid, ':STATUS', $STATUS);
oci_bind_by_name($stid, ':LIC_TYPE', $LIC_TYPE);
oci_bind_by_name($stid, ':OWNER_ID', $IDNum);
oci_bind_by_name($stid, ':LIC_TYPE', $TimeNow);
oci_bind_by_name($stid, ':CREATION_USER_ID', $CREATION_USER_ID);

$r = oci_execute($stid);  // executes and commits

if ($r) {
    print "sucess VIOLATIONS";
}

oci_free_statement($stid);
oci_close($objConnect);

2 个答案:

答案 0 :(得分:1)

:LIC_TYPE有两次限制,:CREATION_DATE从不:

变化:

oci_bind_by_name($stid, ':LIC_TYPE', $LIC_TYPE);
oci_bind_by_name($stid, ':OWNER_ID', $IDNum);
oci_bind_by_name($stid, ':LIC_TYPE', $TimeNow);

要:

oci_bind_by_name($stid, ':LIC_TYPE', $LIC_TYPE);
oci_bind_by_name($stid, ':OWNER_ID', $IDNum);
oci_bind_by_name($stid, ':CREATION_DATE', $TimeNow);

答案 1 :(得分:1)

您错过CREATION_DATE粘贴LIC_TYPE两次,更改倒数第二行

oci_bind_by_name($stid, ':CREATION_DATE', $CREATION_DATE); // assume var name