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

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.
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 SQL Server下载
  • ¥15 python如何将动态的多个子列表,拼接后进行集合的交集
  • ¥20 vitis-ai量化基于pytorch框架下的yolov5模型
  • ¥15 如何实现H5在QQ平台上的二次分享卡片效果?
  • ¥15 python爬取bilibili校园招聘网站
  • ¥30 求解达问题(有红包)
  • ¥15 请解包一个pak文件
  • ¥15 不同系统编译兼容问题
  • ¥100 三相直流充电模块对数字电源芯片在物理上它必须具备哪些功能和性能?
  • ¥30 数字电源对DSP芯片的具体要求