Skip to content

Instantly share code, notes, and snippets.

@dachi023
Last active August 29, 2015 14:14
Show Gist options
  • Save dachi023/9a578bac2c7780dcb0b3 to your computer and use it in GitHub Desktop.
Save dachi023/9a578bac2c7780dcb0b3 to your computer and use it in GitHub Desktop.
OracleではIN句に1000件しか入れられないので1000件ごとに切る
createInQuery = (column, list) ->
max = 1000
queries = []
i = 0
while i < Math.ceil list.length / max
end = if list.length < (i + 1) * max then list.length else (i + 1) * max
val = list
.slice i * max, end
.join "','"
queries.push "#{column} IN('#{val}')"
i++
result = queries.join " OR "
"(#{result})"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment