开发者

postgresql / greenplum parameter binding on jdbc, why does it think its a column name?

I have a query that looks something like this:

SELECT A.A, A.B, B.A, B.C, B.D
FROM tableone A, tabletwo B
WHERE A.A = B.A
AND B.C = :p_name

When the param :p_name is set to FOO I get an error like this:

[42703] ERROR: column "FOO" does not exist

When I manually set it to include single quotes 'FOO' it works.

I've tried padding escaped single quotes. I've tried the quote_* functions. I've ried using "@" "$" and "?" params stypes. This keeps popping up.

EDIT

Eliminating as much as I can, I tried the following from the sql console in IntelliJ

SELECT * from A where A.B = :p1 开发者_Go百科
SELECT * from A where A.B = ? 
SELECT * from A where A.B = @p1

And adding "Foo" the parameter to in the edit box. In all three cases, I get the same problem. When I add 'Foo' to the edit box, I get the results I expect.

I also used preparedStatement and ? rather than callableStatement with :p1 and also got the same results.

What am I doing wrong?

EDIT

Removing "stringtype=unspecified" from the JDBC URL seems to make the problem go away. This is why you shouldn't just copy snippets or other peoples code and just assume it will work for you.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜