I'm trying to build a query that runs against an Oracle database our group has read access to that pulls down results for insertion and modification in a local copy under our control. I've got my query built but I've run into a small problem. To return the results of my query, I can't use a BETWEEN because of the way the DB is indexed; using date ranges causes it to run too slow and the PK doesn't increment sequentially. Instead, I have to loop through an array of values and match those to the PK.
Normally, for something like this against SQL server, I'd throw something like this at it:
AND (
1=1
<cfloop array="#orderHeaderNumArray#" index="i">
OR TABLENAME.S_HEADER_NUMBER LIKE '#i#%'
</cfloop>
)
Every time I've tried a 1=1 against an Oracle query however, I always get a UTF-8 error. In the past, I've just half-assed a solution by setting a known-non-existent value as a conditional, but I was wondering if #1 is this an Oracle limitation or a CF one and #2 if there was a better solution along the lines of an always true instead of an always false conditional.
Edit: Server is CF10, but I don't know what version of Oracle we're using.
AND (
1=1
<cfloop array="#orderHeaderNumArray#" index="i">
OR TABLENAME.S_HEADER_NUMBER LIKE '#i#%'
</cfloop>
)
Does not work in Oracle or ColdFusion. Consider
AND (
1=0
<cfloop array="#orderHeaderNumArray#" index="i">
OR TABLENAME.S_HEADER_NUMBER LIKE '#i#%'
</cfloop>
)
If you are really concerned about the performance of 1=0
AND (
<cfloop array="#orderHeaderNumArray#" index="i">
<cfif i NEQ orderHeaderNumArray[1]> OR </cfif> TABLENAME.S_HEADER_NUMBER LIKE '#i#%'
</cfloop>
)