简体   繁体   中英

oci_bind_by_name(): ORA-01036

I want to use simple oracle update statement with PHP from variable data on Oracle database, but I am getting the error.

oci_bind_by_name(): ORA-01036: illegal variable name/number

Part of the PHP script.

    $connection = oci_connect(getenv('DB_USERNAME'), getenv('DB_PASSWORD'), getenv('DB_HOST'), 'AL32UTF8');
    $sql = oci_parse($connection, "SELECT * FROM TG_EVENT WHERE
    result = 0
    AND regnum IS NOT NULL
    AND customer_id ='1872680'
    AND status_now IN (568, 569, 570)
    AND status_now != status_was");
    oci_execute($sql);
    
    $res = oci_fetch_all($sql, $rows, null, 1000, OCI_FETCHSTATEMENT_BY_ROW);
$update = oci_parse($connection, "UPDATE TG_EVENT SET result = '1'  WHERE customer_id = :customer_id");
oci_bind_by_name($update, ':cutomer_id', $result['CUSTOMER_ID']);
oci_bind_by_name($update, ':regnum', $result['REGNUM']);
oci_bind_by_name($update, ':status_now', $result['STATUS_NOW']);
oci_execute($update);

There are several errors in your code

1- oci_bind_by_name($update, ':cutomer_id', $result['CUSTOMER_ID']); should be

oci_bind_by_name($update, ':customer_id', $result['CUSTOMER_ID']);

ie you wrote :cutomer_id instead of :cu s tomer_id

2- :regnum and :status_now bind variables are not in your query, so remove them or change your query to add these bind variables

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM