Help with PL script-absolute newbie

jmwebguy's Avatar, Join Date: Jul 2009
Newbie Member
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.
0
pradeep's Avatar, Join Date: Apr 2005
Team Leader
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";
}