I need to compare 4000 records in Access to another database (Oracle) using SQL via the IN function. It's limited to 1000 expressions, which means I need to split it up 4 times and run the SQL 4 times or create 4 IN statements in the SQL, which I would rather do so that I only run this query once.
So I extract all 4000 records from access into rec1
This rec1 will have 4000 records in it (could have 2,000 to 20,000 at any given time, in that case I would need to create 20 strings of 1000 each ...woof)
Now I need to split rec1 into 4 strings of 1000 each:
empstr1 (first 1000 expressions strung together)
empstr2 (second 1000 expressions strung together)
empstr3 (third 1000 expressions strung together)
empstr4 (fourth 1000 expressions strung together)
I have code that will delete the last comma
And then I'll just plug the strings into the SQL that hits the Database:
Any ideas or links on how to do this?
So I extract all 4000 records from access into rec1
Code:
sqlstr = select eenum from tblEmployee
rec1.open, sqlstr, con1
This rec1 will have 4000 records in it (could have 2,000 to 20,000 at any given time, in that case I would need to create 20 strings of 1000 each ...woof)
Now I need to split rec1 into 4 strings of 1000 each:
Code:
empstr1 = ""
Do While Not rec1.EOF
empstr1 = empstr1 & rec1!eenum & ","
rec1.MoveNext
Loop
...and do this 4 times
empstr1 (first 1000 expressions strung together)
empstr2 (second 1000 expressions strung together)
empstr3 (third 1000 expressions strung together)
empstr4 (fourth 1000 expressions strung together)
I have code that will delete the last comma
And then I'll just plug the strings into the SQL that hits the Database:
Code:
SELECT EENUM
FROM tblEmp
WHERE EENUM IN(" & empstr1 & ")
OR EENUM IN(" & empstr2 & ")
OR EENUM IN(" & empstr3 & ")
OR EENUM IN(" & empstr4 & ")
Any ideas or links on how to do this?