Last active
August 29, 2015 14:14
-
-
Save dachi023/9a578bac2c7780dcb0b3 to your computer and use it in GitHub Desktop.
OracleではIN句に1000件しか入れられないので1000件ごとに切る
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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