Deal with in clauses in SQL Server

satya - Fri Nov 16 2012 17:04:07 GMT-0500 (Eastern Standard Time)

It has the following support


#**************************************************************************
#********** Aspire string substitution support
#**************************************************************************
aspire.substitutions.quote=aspire.translators.OracleQuote
aspire.substitutions.empty=aspire.translators.GeneralTranslator
aspire.substitutions.urlEncode=aspire.translators.GeneralTranslator

# future stuff
request.aspire.translators.quote.className=com.ai.common.SimpleQuoteTranslator
request.aspire.translators.OracleQuote.className=com.ai.common.OracleQuoteTranslator
request.aspire.translators.GeneralTranslator.className=com.ai.common.GeneralTranslator

#06/25/2012: Supports in clauses based on ids
aspire.substitutions.sqlids=aspire.translators.sqlids1
aspire.substitutions.sqlstrings=aspire.translators.sqlstrings

request.aspire.translators.sqlids.className=com.ai.common.SQLInIdsClauseTranslator
request.aspire.translators.sqlids1.className=com.ai.common.SQLServerInIdsClauseTranslator
request.aspire.translators.sqlstrings.className=com.ai.common.SQLInStringsClauseTranslator

satya - Fri Nov 16 2012 17:05:19 GMT-0500 (Eastern Standard Time)

You can do


in ({some-ids.sqlids})

or

in ({some-strings.sqlstrings})

satya - Fri Nov 16 2012 17:05:47 GMT-0500 (Eastern Standard Time)

Use null if there are no ids


in (null)

satya - Fri Nov 16 2012 17:06:58 GMT-0500 (Eastern Standard Time)

single quote strings and avoiding the last comma


in response to "arg1,arg2,arg3"
in ('arg1','arg2','arg3')

if empty

in ('')

satya - Fri Nov 16 2012 17:07:28 GMT-0500 (Eastern Standard Time)

Of course you can do this in the stored proc if you want to

Of course you can do this in the stored proc if you want to