batching sql inserts
batching sql inserts 2nd try
corrected bugs

sql is now correctly formatted