select语句中的interbase错误

时间:2014-04-28 10:10:03

标签: php syntax-error interbase

亲爱的,我从我的php得到了错误:

PHP Warning:  ibase_query(): Dynamic SQL Error expression evaluation not supported Strings cannot be added or subtracted in dialect 3  in /home/jeinqa/www/oqc/getsch.php on line 22

来自我的剧本:

define("DBNAME","10.230.38.111:/var/lib/firebird/data/OCS_FA.fdb");
define("DBUSER","USER"); // user name
define("DBPASS","USER"); // password
$dbh = ibase_connect(DBNAME,DBUSER,DBPASS) or die(_ERROR15.": ".ibase_errmsg());

    $stmt = "SELECT FIRST 10 LINE_NAME, MODEL_ONLY || ' ' || VER_ONLY as MODEL, PROD_NO,
                     (RIGHT(SERIAL_NO_UP,-4)-RIGHT(SERIAL_NO_LOW,-4))+1 as QTY, START_SERIAL, 
                        SERIAL_NO_LOW, SERIAL_NO_UP, PROD_DATE 
                FROM DOC_TO";
    $sth = ibase_query($dbh, $stmt);

这是我第一次使用interbase。

1 个答案:

答案 0 :(得分:0)

您尝试减去2个字符串(RIGHT(SERIAL_NO_UP,-4)RIGHT(SERIAL_NO_LOW,-4)

相反,在尝试对它们进行数学运算之前,CAST这些值为整数:

(CAST(RIGHT(SERIAL_NO_UP,-4) AS INTEGER)-CAST(RIGHT(SERIAL_NO_LOW,-4)
AS INTEGER))+1 as QTY