01745:运行汇总代码时出现无效的主机/绑定变量名称警告。我不知道为什么会这样,请帮忙!我觉得我的绑定一定有问题,但我看不出有什么问题。我的$ Start和$ End变量看起来像DD-MM-YY。我在下面列出了PHP代码。谢谢!
PHP:
<?php
$year_Echo = '2013';
$yearTruncation = substr($year_Echo, 2);
$yearTruncationMinusOne = $yearTruncation-1;
$Start = ('1-OCT-'.$yearTruncationMinusOne);
$End = ('30-SEP-'.$yearTruncation);
echo "Start = ".$Start." End = ".$End." Year Truncation Minus One = ".$yearTruncationMinusOne."<br>";
/*** connect or WFO DB ***/
$db = oci_connect('query','pw','server:1521/view');
if (!$db){
$e = oci_error();
trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
}
$query = "SELECT * FROM db.cooldb WHERE (STATUS = 'ACTIVE' OR STATUS = 'CLOSED') AND NUMBER <> ' '
AND AMENDMENT_DATE_CREATED
BETWEEN :start AND :end
ORDER BY AMENDMENT_DATE_CREATED DESC";
$runQuery = oci_parse($db, $query);
oci_bind_by_name($runQuery, ":start", $Start);
oci_bind_by_name($runQuery, ":end", $End);
oci_execute($runQuery);
while($row = oci_fetch_array($runQuery, OCI_ASSOC+OCI_RETURN_NULLS))
{
echo $row['AMENDMENT_DATE_CREATED']." ".$row['TITLE']."<br>";
}
?>
错误:
Warning:
oci_execute() [function.oci-execute]: ORA-01745: invalid host/bind variable name
答案 0 :(得分:16)
问题是你使用保留的oracle单词(即我认为“:end”是罪魁祸首)是绑定变量名,这是不允许的。
尝试将其更改为“:finish”或类似内容,它应该可以正常工作。