On 09/09/2014 10:20 AM, Kessler, Joerg wrote:
Hi,
I want to execute select statement on a table using a Java program and
JDBC. The statement is actually not very difficult:
SELECT MSG_NO, SEND_TO, CREATED_TIME, CONTENT, ENCRYPTION_KEY FROM
TESTTABLE WHERE SEQ_ID = ? AND (MSGSTATE IS NULL OR MSGSTATE = 'A')
What does the Java String value passed to prepareStatement() look like?
Sounds like your single-quotes around A have been eaten somehow...
When this statement is executed by a test I receive errors like
Column 'A' is either not in any table in the FROM list or appears within
a join specification and is outside the scope of the join specification
or appears in a HAVING clause and is not in the GROUP BY list. If this
is a CREATE or ALTER TABLE statement then 'A' is not a column in the
target table.
When I change the statement to
SELECT MSG_NO, SEND_TO, CREATED_TIME, CONTENT, ENCRYPTION_KEY FROM
TESTTABLE WHERE SEQ_ID = ? AND MSGSTATE IS NULL
there is no problem. Also when I execute the above statement via Eclipse
Database Development/SQL Scrapbook using a fix SEQ_ID the statement is
executed without error.
What am I doing wrong?
Best Regards,
Jörg
--
Regards,
Dyre