powerhouse has asked for the wisdom of the Perl Monks concerning the following question:
That will pick up only one or two... I just wrote that code to show you what I'm doing, but there is a lot more code, that is not the complete code or the clean version of it so forgive my errors that I put... the code works now, but it excludes paychecks that have 3 or more checks combined into one because the amounts won't match.my $_checkNo = 0; my $_checkAmt = 1; my $_emp_id = 2; my $_paydate = 3; my @fileparts = split(/\,/, $_line); # Get potid from pot(Pay Out Tracking) table my $_potid = $dbh->selectrow_array(qq{SELECT `potid` FROM `pot` WHERE +`status` = "preissue" AND `amount` = ? AND `adpid` = ?}, undef, $file +parts[$_checkAmt], $fileparts[$_emp_id]); if(!$_potid) { # ok, the amount does not match any, so I'm sure they had more tha +n one transaction.... Check for two: ($_potid,$_chkamt) = $dbh->selectrow_array(qq{SELECT `potid`,`amou +nt` FROM `pot` WHERE `status` = "preissue" AND `adpid` = ?}, undef, $ +fileparts[$_emp_id]); if($_potid) { $_newChkAmt = sprintf('%.2f', $fileparts[$_checkAmt] - $_chkam +t); $_potid2 = $dbh->selectrow_array(qq{SELECT `potid` FROM `pot` +WHERE `status` = "preissue" AND `amount` = ? AND `adpid` = ?}, undef, + $_newChkAmt, $fileparts[$_emp_id]); } if($_potid && $_potid2) { $inserted = $dbh->do(qq{UPDATE `pot` SET `status` = "issued", +`checkno` = ?, `statuschanged` = ? WHERE (`potid` = ? OR `potid` = ?) +}, undef, $fileparts[$_checkNo], $fileparts[$_paydate], $_potid, $_po +tid2); } if($inserted) { $_success++; } else { $_failed++; } }
I see the logic in my head but cannot figure out a way to get it to work... what I want it to do is get MySQL to update all the records that have that employee identifier and are matched and the amounts all equal the amount I am giving it.$dbh->do(qq{UPDATE `pot` SET `status` = "issued", `checkno` = ?, `stat +uschanged` = ? WHERE `status` = "preissue" AND `apdid` = ? AND $filep +arts[$_checkAmt] IN SUM(amount)}, undef, @placeholder); # @placeholder will contain all the values for the ?....
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: payroll, mysql and perl question
by graff (Chancellor) on Jan 02, 2008 at 06:47 UTC | |
by powerhouse (Friar) on Jan 02, 2008 at 16:59 UTC | |
by graff (Chancellor) on Jan 02, 2008 at 19:44 UTC | |
by powerhouse (Friar) on Jan 02, 2008 at 23:30 UTC | |
|
Re: payroll, mysql and perl question
by igelkott (Priest) on Jan 02, 2008 at 06:58 UTC | |
by powerhouse (Friar) on Jan 02, 2008 at 17:05 UTC | |
|
Re: payroll, mysql and perl question
by perrin (Chancellor) on Jan 02, 2008 at 06:41 UTC |