1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Help with PL script-absolute newbie

Discussion in 'Perl' started by jmwebguy, Jul 6, 2009.

  1. jmwebguy

    jmwebguy New Member

    Joined:
    Jul 6, 2009
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    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.
     
  2. pradeep

    pradeep Team Leader

    Joined:
    Apr 4, 2005
    Messages:
    1,646
    Likes Received:
    86
    Trophy Points:
    0
    Occupation:
    Programmer
    Location:
    Kolkata, India
    Home Page:
    Code:
    $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";
    }
    
     
    shabbir likes this.

Share This Page