0

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.

4

2 に答える 2

2
AND ( 
  1=1
  <cfloop array="#orderHeaderNumArray#" index="i">
     OR TABLENAME.S_HEADER_NUMBER LIKE '#i#%' 
  </cfloop>
  )

Oracle または ColdFusion では機能しません。検討

AND ( 
  1=0
  <cfloop array="#orderHeaderNumArray#" index="i">
     OR TABLENAME.S_HEADER_NUMBER LIKE '#i#%' 
  </cfloop>
  )

のパフォーマンスを本当に気にする場合は、1=0

AND ( 
  <cfloop array="#orderHeaderNumArray#" index="i">
     <cfif i NEQ orderHeaderNumArray[1]> OR </cfif> TABLENAME.S_HEADER_NUMBER LIKE '#i#%' 
  </cfloop>
  )
于 2013-09-20T14:58:53.873 に答える
0

1 = 1 を使用することは理想的ではないことに同意しますが、それが存在する理由についてコメントを含める限り、許容できると思います。

しかし、質問の要点として、代わりに主キーをそれ自体に割り当ててみましたか? すなわち

AND ( 
    id = id
    <cfloop array="#orderHeaderNumArray#" index="i">
        OR TABLENAME.S_HEADER_NUMBER LIKE '#i#%' 
    </cfloop>
)
于 2013-09-21T11:29:00.473 に答える