The "iBatis In Action" text shows how to pass an integer to a mapped
statement without using a parameter map:
<select id=....>
select xxxx
where accountId = #value#
</select>
Then call the mapped statement with this:
account = (Account) sqlMap.queryForObject("...", new Integer(1));
I've tried doing something similar but with two noticeable differences:
(1) using: queryForList
(2) passing a string as the parameter
My select statement has an ORDER BY clause, and the string I pass is the
name of a field in the table. The query works fine right now if I put the
text string into a map and pass that map to the statement, but I'm trying to
do it instead with a simple inline parameter (no parameter map).
Here is the line inside my <select> tags.
ORDER BY = #sortcrit:CHAR#
I followed instructions in the textbook for telling iBatis about the data
type. According to java.sun.com, JDBC type CHAR represents a "small,
fixed-length character string."
Here is my call statement:
String sortcrit = "LABEL";
albums = sqlMap.queryForList("getAlbumInfo", sortcrit);
I get the following error message when I run this query:
java.lang.RuntimeException: Error executing sqlMap query. Cause:
com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in swingCat-sqlMap.xml.
--- The error occurred while applying a parameter map.
--- Check the getAlbumInfo-InlineParameterMap.
--- Check the statement (query failed).
--- Cause: org.postgresql.util.PSQLException: ERROR: syntax error at or near
"="
Is it possible to use a string as an inline parameter? Any idea what I am
doing wrong here? Thank you very much for any assistance you can provide.
--
View this message in context:
http://old.nabble.com/Inline-Parameters---Passing-a-String-tp26733822p26733822.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]