--- to_csv.pl 2000/06/14 09:42:59 1.1 +++ to_csv.pl 2000/07/18 08:24:39 1.2 @@ -1,14 +1,27 @@ #!/usr/local/bin/perl -w +# export e-mail adresa za Filipa, +# Usage: +# +# to_csv.pl [yyyy-mm-dd] +# +# yyyy-mm-dd ... datum od kojeg se vrši export (datum zadnjeg exporta) + use DBI; +my $sql_where; + +if (defined($ARGV[0])) { + $sql_where = " and datum_unesen > '$ARGV[0]'"; +} + my $mydbh = DBI->connect("DBI:Pg:dbname=informatika","","") || die $DBI::errstr; $mysth = $mydbh->prepare(" - select ime,prezime,alias||'\@pliva.hr' from osobe,e_mail where e_mail.osoba_id=osobe.id + select ime,prezime,alias||'\@pliva.hr' as email from osobe,e_mail where e_mail.osoba_id=osobe.id $sql_where ") || die $mydbh->errstr(); $mysth->execute() || die $mysth->errstr(); -print "#",join("\t",@{ $mysth->{NAME} }),"\n"; +print "#",join(",",@{ $mysth->{NAME} }),"\n"; while (@myarr = $mysth->fetchrow_array() ) { print join(",",@myarr),"\n"; }