2

Have the following query that is giving error while executing through java driver, no errors while executing on 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

Here is the error

    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'
2
  • What driver do you use? Commented Jun 19, 2013 at 7:49
  • If pr.site_id is a numeric column you should not use single quotes for the comparison value. '150' is a string value, 150 is a number. Commented Jun 19, 2013 at 8:02

1 Answer 1

3

Try using the Dollar-quoted notation.

Instead of having pr.site_id = '150' try it with something like

pr.site_id = $$150$$

Most probably your JDBC driver has problem distinguishing the two different quotes ' (&#39) and ` (&#96)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.