【问题标题】:Oracle-00972 : identifier too long what's wrong with my SQL?Oracle-00972:标识符太长 mySQL 有什么问题?
【发布时间】:2012-07-19 21:27:39
【问题描述】:
<?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);
?>  

我得到这个输出:

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

【问题讨论】:

标签: php sql oracle


【解决方案1】:

这里有很多问题。

  1. 最简单的答案是您需要使用单引号 (') 而不是双引号(请参阅 String Literals in Oracle Database SQL Reference
  2. 您确实应该使用oci_bind_by_name 之类的东西,而不是盲目地将您的值插入到查询中。为您节省解析和潜在的 SQL 注入。
  3. 自 PHP 5.4 起,ociparseociexecute 已弃用。而不是这些,您应该分别使用oci_parseoci_execute

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2011-02-16
  • 2012-07-09
  • 2012-12-22
  • 1970-01-01
  • 2020-07-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多