From: | sarlav kumar <sarlavk(at)yahoo(dot)com> |
---|---|
To: | Sean Davis <sdavis2(at)mail(dot)nih(dot)gov> |
Cc: | pgsqlnovice <pgsql-novice(at)postgresql(dot)org> |
Subject: | Re: SQL from shell script |
Date: | 2005-01-14 20:32:30 |
Message-ID: | 20050114203230.67424.qmail@web51306.mail.yahoo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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.
From | Date | Subject | |
---|---|---|---|
Next Message | John DeSoi | 2005-01-15 13:37:57 | Re: Common question: what's wrong |
Previous Message | Sean Davis | 2005-01-14 20:05:08 | Re: SQL from shell script |