dongliyu3278 2012-07-19 21:27
浏览 230
已采纳

Oracle-00972:标识符太长我的SQL出了什么问题?

<?php

// This leaves the db connection in $conng require_once('/tms/http/html_docs/tease/csp/csp_tease.php');

    /* This a logging function. When called with:
     */

    function log_tkt_to_db($tkt_number, $date, $uid, $description, $conng)
    {
        echo "$tkt_number|$date|$uid|$description<br>";

        $sqlinsert = "insert into TEASE_TKTLOGS  VALUES ( \"$tkt_number\", \"$date\", \"$description\",  \"$uid\")";
        echo $sqlinsert . "<br>";
        $insert = OCIParse($conng, $sqlinsert);
        // OCIExecute($insert, OCI_COMMIT_ON_SUCCESS);
        OCIExecute($insert);
    }

log_tkt_to_db("00000000", "07/13/2012", "jt898u", "this a test, this is only a test", $conng);
?>  

I get this output:

00000000|07/13/2012|jt898u|this a test, this is only a test
insert into TEASE_TKTLOGS (TICKET, DATE_TIME, CHANGE_DESC, ATTUID) VALUES ( "00000000", "07/13/2012", "this a test, this is only a test", "jt898u")

Warning: ociexecute() [function.ociexecute]: ORA-00972: identifier is too long in /appl/tms/http/html_docs/tease/dblog.php on line 17
  • 写回答

1条回答

  • dsigg21445 2012-07-19 21:38
    关注

    There are multiple things wrong here.

    1. The simplest answer is that you need to use single quote marks (') instead of double quotes (see String Literals in Oracle Database SQL Reference)
    2. You really should use something like oci_bind_by_name instead of blindly inserting your values into the query. Saves you a parse and a potential SQL injection.
    3. ociparse and ociexecute are deprecated as of PHP 5.4. Instead of these you should use, respectively, oci_parse and oci_execute.
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?