ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Niels Beekman" <n.beek...@wis.nl>
Subject RE: sql server 2k parameterized queries
Date Thu, 23 Mar 2006 11:26:34 GMT
Yes, you cannot parameterize clauses in SQL.
Use the $-syntax: AND $shows$

Niels

-----Original Message-----
From: Bob [mailto:gnomeking@gmail.com] 
Sent: donderdag 23 maart 2006 9:38
To: user-java@ibatis.apache.org; lmeadors@apache.org
Subject: Re: sql server 2k parameterized queries

On 23/03/06, Larry Meadors <lmeadors@apache.org> wrote:
> Can you post the mapped statement?

Certainly - but it is very simple!

	<statement id="getPayoutOrgData"
resultClass="java.util.HashMap">
		SELECT EVENT.EVENTCD,
			sum(WTRANS.NETSTAMT) AS NET_VALUE
		FROM WTRANS
			INNER JOIN EVENT
				ON WTRANS.EVENTCD = EVENT.EVENTCD
		WHERE WTRANS.TRX_TYPE='S'
			AND WTRANS.[FUNCTION]=1
			AND #shows#
		GROUP BY EVENT.EVENTCD, EVENT.NAME
		ORDER BY EVENT.NAME
	</statement>

I am querying with:

        Map filters = new HashMap();
        filters.put("shows", shows);
        List ret = getSqlMap().queryForList(
                    "getPayoutOrgData",
                    filters);

shows is a string of the following format: (it is dynamically created
and can be quite long, but the example which is falling over has just
one entry)
(WTRANS.EVENTCD="ABC" OR WTRANS.EVENTCD="DEF")

... thinking about it, is that the problem? Can I use a parameterized
statement when an entire where clause is dynamically generated?

Bob

Mime
View raw message