ORA-00900:php中的SQL语句无效,但可在sqlplus中使用
我试图用php执行一个.SQL文件中的SQL查询,但它给出了标题中提到的错误。但是,当我将其粘贴到sqlplus或从那里运行文件时,一切都很好。以下是查询:ORA-00900:php中的SQL语句无效,但可在sqlplus中使用,php,sql,oracle,Php,Sql,Oracle,我试图用php执行一个.SQL文件中的SQL查询,但它给出了标题中提到的错误。但是,当我将其粘贴到sqlplus或从那里运行文件时,一切都很好。以下是查询: SELECT name, followers, friends, Nvl(no_of_tweets, 0) statuses, Nvl(mentioned, 0) mentioned, rts, Nvl(favs, 0) favs,
SELECT name,
followers,
friends,
Nvl(no_of_tweets, 0) statuses,
Nvl(mentioned, 0) mentioned,
rts,
Nvl(favs, 0) favs,
( ( 10 * followers + 5 * friends + 12 * Nvl(no_of_tweets, 0) + 15 *
Nvl(mentioned, 0) + 14 * rts + 15 * Nvl(favs, 0) ) / 10 ) h_index
FROM users U
left join (SELECT T.user_id_str,
Count(*) AS no_of_tweets,
SUM(retweets) rts,
SUM(favorites) favs,
mentioned
FROM tweets T
left join (SELECT user_id_str,
Count(*) AS mentioned
FROM mentions
GROUP BY user_id_str) M
ON T.user_id_str = M.user_id_str
GROUP BY T.user_id_str,
mentioned) C
ON U.user_id_str = C.user_id_str
ORDER BY h_index DESC;
有哪些调试方法可以帮助我发现问题或此命令的错误
这是我的PHP代码:
$query = ':sql';
$st_sql = oci_parse($con, $query);
oci_bind_by_name($st_sql, ':sql', file_get_contents($path));
$r = oci_execute($st_sql);
if (!$r) {
$e = oci_error($st_sql);
echo $e['message'];
}
使用nick(现在已删除)的答案,并删除查询末尾的分号。好的,它成功了,感谢未来的读者:这不是如何使用绑定变量。应该使用它们将数据替换为语句,因为绑定变量被视为数据,而不是语句。查看或Oracle的免费。