通过java驱动程序执行时出现以下查询错误,在DBVisualizer上执行时没有错误
SELECT pr.id,
pr.name,
CDPC.category_id,
CDPC.category_depth,
CDPC.product_count,
pr.primary_category_id
FROM ics_products_to_include_tmp inc
INNER JOIN catalog.products pr ON inc.product_id = pr.id
INNER JOIN catalog.products_in_categories pic ON pic.product_id = pr.id AND pic.active = true
INNER JOIN catalog.categories CC ON CC.id = pic.category_id AND CC.active = true
INNER JOIN category_depth_product_count_tmp CDPC
ON CDPC.category_id = CC.id
AND NOT EXISTS (SELECT *
FROM ics_products_cds_ids_tmp cds
WHERE cds.product_id = pr.id)
WHERE pr.site_id = '150'
ORDER BY pr.id
这是错误
Exception in thread "main" org.postgresql.util.PSQLException: ERROR: syntax error at end of input Position: 495 at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2103) at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1836) at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257) at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:512) at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:388) at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:381) at com.cnetchannel.ics.loader.IntermediateDatafeedGenerator.main(RRToIntermediateLoader.java:798) Disconnected from the target VM, address: '127.0.0.1:51077', transport: 'socket'
答案 0 :(得分:2)
尝试使用Dollar-quoted表示法。
而不是pr.site_id = '150'
尝试使用
pr.site_id = $$150$$
很可能你的JDBC驱动程序在区分两个不同的引号'(&#39)和`(&#96)
时有问题