开发者

PHP / DB2 Error on preparing statement

I am getting this error when trying to db2_prepare() a statement with PHP 5.3.3

I've done other db2_prepare statements without error, any idea what might be wrong here?

"Erro开发者_StackOverflow中文版r: 42601: Token '?' was not valid. Valid tokens: ROW ROWS. SQLCODE=-104"

This is the line of code I am having trouble on.

$sql_featRand = "SELECT filine, fiitem FROM files.tablex ORDER BY RAND() FETCH FIRST ? ROWS ONLY";

$db_prepRand = db2_prepare($dbConnection, $sql_featRand); if ($db_prepRand === FALSE) { echo "Unable to prepare statement- Error: " . db2_stmt_error() . ": " . db2_stmt_errormsg(); die(); }


This is because you can't use a parameter marker in the FETCH FIRST n ROWS clause. You have to specify a real value.

Unfortunately this means that you'll either have to prepare multiple statements or just stop fetching rows after reading the number of rows you're interested in.


You have to have a db2_execute statement that converts the ? in your prepared select statement to a number.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜