1

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

2 Answers 2

1

: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);
Sign up to request clarification or add additional context in comments.

2 Comments

$DateToday = date("d/m/y"); when insert date --> error appeared to me 'ORA-01843: not a valid month'
@mohammadrababah see here: stackoverflow.com/questions/7066978/…
1

You missed CREATION_DATE pasted LIC_TYPE twice,change second last line

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.