powerhouse has asked for the wisdom of the Perl Monks concerning the following question:
So when ADP sends their checks to them and we download the check reconciliation, it would show this:----------------------------------------------------- |MemberId|ADPID|PayoutAmount|status|statuschanged|t ----------------------------------------------------- |1 |101 |401.67 |Preissued|1206583466|2008-03-26 13:34:48 ----------------------------------------------------- |3 |101 |308.21 |Preissued|1206583466|2008-03-26 13:34:48 ----------------------------------------------------- |5 |101 |904.34 |Preissued|1206583466|2008-03-26 13:34:48 ----------------------------------------------------- |8 |101 |603.98 |Preissued|1206583466|2008-03-26 13:34:48 -----------------------------------------------------
So, what we need to do is if they had checks spaning two pay out dates, the amount may not equal all the preissued checks it may be less so I need the automated programming to find those that equal the amount of the check they sent, for example if that adp file said this instead:File #, Amount, Check Number, Pay Date 101, 2218.20, 10108, 03/26/2008
so it would not equal all the preissued checks, therefore, I need to find a way for Perl to find only those that have a sum of 1313.86, that are preissued and belong to that member only.File #, Amount, Check Number, Pay Date 101, 1313.86, 10108, 03/26/2008
Anyhow, I hope I made it clear what I need to do. I need to update records that may not include all of their preissued checks but find the ones that are included in the amount of the check.# Wrote right now, not a copy and paste, so not exact... open(FILE, "/path/to/apd/file.csv") or die "could not open file: $!"; my @_FILE = <FILE>; close(FILE); foreach my $_line (@_FILE) { $_line =~ s/\s+//g; my @_fileparts = split(/,/, $_line); my $sth = $dbh->prepare(qq{SELECT * FROM `payouts` WHERE `status` = +"Preissue" AND `adp_id` = ?}); $sth->execute($_fileparts[0]); while(my $_pay = $sth->fetchrow_hashref()) { # See this will not work because it may include the one record not +included in this file record that I split, so I cannot update this ch +eck ID } $sth->finish(); }
But that gives me an error saying illegal grouping.$sth = $dbh->prepare(qq{ select * from payouts where SUM(amount) = ?}) +; $sth->execute($_fileparts[2]);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Using Perl to update multiple Database Records but not all
by perrin (Chancellor) on Mar 27, 2008 at 02:59 UTC | |
|
Re: Using Perl to update multiple Database Records but not all
by pc88mxer (Vicar) on Mar 27, 2008 at 15:52 UTC | |
|
Re: Using Perl to update multiple Database Records but not all
by apl (Monsignor) on Mar 27, 2008 at 12:09 UTC |