mohammad rababah mohammad rababah -3 years ago 151
PHP Question

PHP oci_execute(): ORA-01008: not all variables bound

I'm trying to insert data from php to oracle

but I have error

oci_execute(): ORA-01008: not all variables bound


Note: insert some data not all filed in table.

$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);

Answer Source

:LIC_TYPE is bounded two times and :CREATION_DATE never:

Change:

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);

To:

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);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download