简体   繁体   English

Oracle-00972:标识符过长我的SQL有什么问题?

[英]Oracle-00972 : identifier too long what's wrong with my 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

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 ) 最简单的答案是,您需要使用单引号( ' )而不是双引号(请参见《 Oracle数据库SQL参考》中的“ 字符串文字” )。
  2. You really should use something like oci_bind_by_name instead of blindly inserting your values into the query. 您确实应该使用类似oci_bind_by_name而不是盲目地将值插入查询中。 Saves you a parse and a potential SQL injection. 为您节省解析和潜在的SQL注入。
  3. ociparse and ociexecute are deprecated as of PHP 5.4. 从PHP 5.4开始不推荐使用ociparseociexecute Instead of these you should use, respectively, oci_parse and oci_execute . 代替这些,您应该分别使用oci_parseoci_execute

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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