I have a problem with a SQL select statement that I need to build dynamically.
Most of the select remains constant, but depending on which fields are filled
in on the search form the WHERE clause changes. This code used to be largely
Java when this application ran on Websphere, but having moved it to Tomcat and
JSTL I would rather minimise the Java (I could always write a bean if it is
not possible otherwise, but I would rather not).
I have built a JSTL variable called where, and I then build the SELECT
statement:-
<sql:query>
SELECT dno, action, destination, quantity, updated FROM load
WHERE <c:out value="${where}" />
</sql:query>
When I try to run this I get an SQL exception
(javax.servlet.ServletException) :-
SELECT dno, action, due, destination, quantity, updated FROM load
WHERE area = 'NW'
ORDER BY due DESC FOR READ ONLY
: ERROR: parser: parse error at or near "NW"
The backend DB is Postgres, which seems to work very nicely in all the other
SQL I have thrown at it from JSTL. However the others have fixed SELECT
statements and I put the values in using <sql:param>. In this case I have
one of three basic bits of the WHERE clause, and two secondary search
items, and the thought of having the full set of separate SELECT statements
does not seem right.
I am obviously doing something extreemly silly, can anyone spot it?
David
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]