简体   繁体   中英

ORA-01036 with oci_bind_by_name

I'm trying to make a SELECT from PHP to Oracle database.

Here is the code i did:

 $sql = "SELECT * FROM
        DEV_F.FO_INPUT i,
        DEV_F.FO_MAIN m
        WHERE m.FOM_ID = i.FIN_FATHER
        AND m.FOM_ID = :traceID";

    $stid = oci_parse($this->connexion(), $sql);


    oci_bind_by_name($stid, 'traceID', $this->escapeString($traceID));

    oci_execute($stid);
    oci_fetch_all($stid, $res);

The request is OK in SQLDevelopper, returns no error, . But php returns:

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

I tried to add single quotes, to add semicolons etc… Nothing works, i'm pretty stick here.

Any tips ? Did i miss something ?

您需要这样做,首先使用冒号,但也不需要转义该值,因为绑定将为您处理该值。

oci_bind_by_name($stid, ':traceID', $traceID);

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