Re: SQL from shell script
От | sarlav kumar |
---|---|
Тема | Re: SQL from shell script |
Дата | |
Msg-id | 20050114203230.67424.qmail@web51306.mail.yahoo.com обсуждение исходный текст |
Ответ на | Re: SQL from shell script (Sean Davis <sdavis2@mail.nih.gov>) |
Список | pgsql-novice |
> 4) delete from table1 where criteria1;
>
You want to delete these entries, I assume?Yes, I want to delete the entries.
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.
В списке pgsql-novice по дате отправления: