Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Perl (http://www.go4expert.com/forums/perl/)
-   -   Help with PL script-absolute newbie (http://www.go4expert.com/forums/help-pl-script-absolute-newbie-t18367/)

jmwebguy 6Jul2009 07:58

Help with PL script-absolute newbie
 
Ok, I am not a perl programmer. I had someone write something for me a few years ago.

I am running Windows 2003 server. This script works perfect but I need to add something.

$sth = $dbh->prepare('INSERT INTO RETS_log (thevalue,assoc,task,proptype) select count(mls_acct),\'LBAR\',\'Number to be Deleted\',\'RESI\' from rets_lbar_mlsdata_resi where mls_acct not in (select mls_acct from rets_lbar_mlsdata_resi_compare)');
$sth->execute or die "SQL Error: $DBI::errstr\n";


$sth = $dbh->prepare('delete from rets_lbar_mlsdata_resi where mls_acct not in (select mls_acct from rets_lbar_mlsdata_resi_compare)');
$sth->execute or die "SQL Error: $DBI::errstr\n";
$sth = $dbh->prepare('insert into RETS_log (assoc,task,proptype) values (\'LBAR\',\'Comparison Complete\',\'RESI\')');
$sth->execute or die "SQL Error: $DBI::errstr\n";
$sth = $dbh->prepare('insert into RETS_log (assoc,task,proptype) values (\'LBAR\',\'ALL TASKS COMPLETE\',\'RESI\')');
$sth->execute or die "SQL Error: $DBI::errstr\n";

$sth = $dbh->prepare('insert into RETS_log (assoc,task,proptype) values (\'LBAR\',\'END PROCESS\',\'RESI\')');
$sth->execute or die "SQL Error: $DBI::errstr\n";



Basically, from a DOS prompt I have this running as a scheduled tasks. I need to do an IF..THEN statement. I need to run a MSSQL query (count(*) from thelog)

If the COUNT>7000 then do the next step, else, don't.

Any help would be greatly appreciated.

pradeep 20Jul2009 18:15

Re: Help with PL script-absolute newbie
 
Code: Perl

$sth = $dbh->prepare('INSERT INTO RETS_log (thevalue,assoc,task,proptype) select count(mls_acct),\'LBAR\',\'Number to be Deleted\',\'RESI\' from rets_lbar_mlsdata_resi where mls_acct not in (select mls_acct from rets_lbar_mlsdata_resi_compare)');
$sth->execute or die "SQL Error: $DBI::errstr\n";

if($sth->rows > 7000)
{
    $sth = $dbh->prepare('delete from rets_lbar_mlsdata_resi where mls_acct not in (select mls_acct from rets_lbar_mlsdata_resi_compare)');
    $sth->execute or die "SQL Error: $DBI::errstr\n";
    $sth = $dbh->prepare('insert into RETS_log (assoc,task,proptype) values (\'LBAR\',\'Comparison Complete\',\'RESI\')');
    $sth->execute or die "SQL Error: $DBI::errstr\n";
    $sth = $dbh->prepare('insert into RETS_log (assoc,task,proptype) values (\'LBAR\',\'ALL TASKS COMPLETE\',\'RESI\')');
    $sth->execute or die "SQL Error: $DBI::errstr\n";

    $sth = $dbh->prepare('insert into RETS_log (assoc,task,proptype) values (\'LBAR\',\'END PROCESS\',\'RESI\')');
    $sth->execute or die "SQL Error: $DBI::errstr\n";
}



All times are GMT +5.5. The time now is 16:11.