My company occasionally does some telemarketing (we're a newspaper, not the bad guys!), and so we have to have our own do not call database. Well we were getting the numbers in one format, which has suddenly changed, on us. I now have to take this file:
2065551212,2003-09-24T13:46:00,A
2065551213,2003-09-29T17:29:26,A
2065551214,2003-09-18T00:00:00,D
2065551215,2003-09-18T00:00:00,D
2065551216,2003-09-18T00:00:00,D
2065551217,2003-09-18T00:00:00,D
2065551218,2003-09-18T00:00:00,D
2065551219,2003-09-18T00:00:00,D
2065551220,2003-10-01T14:53:48,A
2065551221,2003-10-09T11:58:38,A
and if there is an "a" after it then add the number to the database, and if there is a "d" then delete the number.
so the first line would look like
insert into phonenumbers (areacode, prefix, suffix) values (206, 555, 1216);
and the 3rd line would like:
delete from phonenumbers where areacode = $1 and prefix = $2 and suffix = $3;
I was hoping to use copy instead of insert for speed reasons. In my initial tests, it took 3 hours to do a line by line insert of every number in the db and 30 seconds to do a copy. Ideas?
ps. I'm using postgresql.
--Bryan