2012-07-19 69 views
1
<?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); 
?> 

我得到这样的输出:Oracle-00972:标识符太长我的SQL有什么问题?

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 
+0

请张贴您的模式 – aingram 2012-07-19 21:34:38

+0

看看这个由于一些原因导致此错误:http://www.coderanch.com/t/80098/Oracle-OAS/ORA-identifier-too-long-at – CodeZombie 2012-07-19 21:35:32

回答

5

有多种事情错在这里。

  1. 最简单的答案是,你需要使用单引号(')而不是双引号(见Oracle Database SQL Reference字符串字面
  2. 你真的应该使用类似oci_bind_by_name,而不是盲目地将自己的价值观进入查询。为您节省解析和潜在的SQL注入。
  3. ociparseociexecute自PHP 5.4起已弃用。代替这些,你应该分别使用oci_parseoci_execute
+0

1)我后来发现http://www.coderanch.com/t/80098/Oracle-OAS/ORA-identifier-too-long-at其中提到了由于引用引起的错误消息。 – 2012-07-20 16:04:53

+0

3)传统安装/代码。 'PHP'在5.2.4。所有现有的代码都使用'ociparse()',所以我也这样做了。 – 2012-07-20 16:25:45