PostgreSQL中输入结束时的语法错误 [英] Syntax error at end of input in PostgreSQL

查看:1585
本文介绍了PostgreSQL中输入结束时的语法错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在MySQL和PostgreSQL中使用了下一条SQL语句,但是在PostgreSQL中失败了。

  db.Query(` SELECT COUNT(*)as N FROM email WHERE address =?`,email)

  pq:F:scan.lM:输入结束时的语法错误S:错误C: 42601P:50R:scanner_yyerrorL:993

什么问题? PostgreSQL中的错误信息是非常神秘的。

解决方案

你没有提供任何有关语言/环境的细节,无论如何,我都会猜测:

MySQL的准备语句原生使用作为参数占位符,但PostgreSQL使用 $ 1 $ 2 尝试用<$替换 c $ c> $ 1 并查看它是否有效:

  WHERE地址= $ 1 




PostgreSQL中的错误信息非常神秘。


一般而言,Postgres错误信息非常明确,但在这种情况下,您已经设法将解析器混淆到了理智之外。 :)

I have used the next SQL statement in both MySQL and PostgreSQL, but it fails in PostgreSQL

db.Query(`SELECT COUNT(*) as N FROM email WHERE address = ?`, email)

with this error:

pq: F:"scan.l" M:"syntax error at end of input" S:"ERROR" C:"42601" P:"50" R:"scanner_yyerror" L:"993"

What's the problem? The error messages in PostgreSQL are very cryptic.

解决方案

You haven't provided any details about the language/environment, but I'll try a wild guess anyway:

MySQL's prepared statements natively use ? as the parameter placeholder, but PostgreSQL uses $1, $2 etc. Try replacing the ? with $1 and see if it works:

WHERE address = $1

The error messages in PostgreSQL are very cryptic.

In general, Postgres error messages are very clear, but in this instance you've managed to confuse the parser beyond sanity. :)

这篇关于PostgreSQL中输入结束时的语法错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆