• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Informix Prepared Statement

 
Hugo Sanchez
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm having the following problem:

- I have a PreparedStatement that works fine with the following SQL (it retrieves a date and converts it to char):

sql = "SELECT TO_CHAR(TO_DATE(M.call_date || ' ' || M.seize_time), ?) part_actual_start,
M.CROSS_REF part_id
FROM DATES_TABLE M"

stmt = con.prepareStatement(sql);
stmt.setString(1, ifxTimeFormat);


- Whenever I attempt to append more text an exception is thrown (I append timezone code to the result)

sql = "SELECT TO_CHAR(TO_DATE(M.call_date || ' ' || M.seize_time), ?) || ' GMT' part_actual_start,
M.CROSS_REF part_id
FROM DATES_TABLE M"

stmt = con.prepareStatement(sql);
stmt.setString(1, ifxTimeFormat)

java.sql.SQLException: A syntax error has occurred.

- The origin of the exception points to the line when the SQL is parsed

stmtCAS = conCAS.prepareStatement(sqlStmtCAS);


The same query runs pretty fine on my console

Have any of you experienced something like this before? How did you manage to solve this?

Thanks in advance
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34207
341
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hugo,
Welcome to JavaRanch!

I haven't used Informix, but the query looks fine. As an alternative, you could add the "GMT" in Java after you've retrieved the result. This would simplify the query too.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic