You could write a simple perl script that looks like:
#!/usr/bin/perl use strict; my $date = shift; #get from command line
my @tables = (qw/ table1 table2 table3 /); #put in your tablenames here foreach my $tablename (@tables) { print "create table temp1 as select * from $tablename where date='$date';\n"; print "COPY temp1 TO '$tablename.$date.txt';\n"; print "DROP table temp1;\n"; print "DELETE FROM $tablename WHERE date='$date';\n"; }
This is kind of what I want to do. The only problem here is that first statement where I create temporary tables, will be selecting data from different tables based on different where clauses. Some of them even use join on tables. So I guess I can't use the foreach statement.
Thanks a lot for the help, this definitely has given me a lead on how to proceed.
Thank you very much,
Saranya
Do you Yahoo!? Yahoo! Mail - You care about security. So do we.