Hello ... I have a script which connected to a MS SQL database ... it hangs
right at the end of the script ... if I check my database it DOES insert all
the information correctly ... it just hangs and never exits ... any ideas??

here is the script ...

!/usr/bin/sybaseperl

$ENV{'SYBASE'}="/opt/sybase";
$ENV{'DSQUERY'}="rodopi";

use DBI;

use Date::Manip;
use Date::Format;

$tomorrow = time2str("%h %d %Y", UnixDate(ParseDate("tomorrow"),"%s"));
$todaystring = &ParseDate("today");
$today = time2str("%m/%d/%Y", UnixDate(ParseDate("today"),"%s"));
$thismonth = time2str("%m/01/%Y", UnixDate(ParseDate("today"),"%s"));
$lastmonth = time2str("%m/01/%Y", UnixDate(ParseDate("lastmonth"),"%s"));

$charge = 3;
$extracharge = 0;
$duration = 6;
$tax = 1.07;

$dbh = DBI->connect("dbi:Sybase:database=XXXXX", "XXXXXX", "XXXXXXX");

$sql = <<_ENDSQL;
SELECT Customers.CustomerID, Plans.PlanID, Emails.PopName,
Emails.EmailAddress, Emails.Password
FROM Plans INNER JOIN Customers ON Plans.CustomerID = Customers.CustomerID
INNER JOIN Emails ON Plans.PlanID = Emails.PlanID
WHERE Emails.PopName="$emailname" AND Emails.EmailAddress="$email" AND
Emails.Password="$password"
_ENDSQL

$sth = $dbh->prepare($sql);
$sth->execute || warn $sth->errstr;

while (@detail = $sth->fetchrow_array) {
        $custid = $detail[0];
        $emailid = $detail[1];
        $popname = $detail[2];
        $address = $detail[3];
        $password = $detail[4];
        $realname = $detail[5];

        print "Custid  :  $custid\n";
        print "EmailId :  $emailid\n";
        print "address :  $address\n";
        print "Popname :  $popname\n";
        print "Password:  $password\n";
        print "Real    :  $real\n";
        print "Today   :  $today\n";
}

#-----------------------------------------------------------------------
# Insert Plan

$exec = qq{ Exec Subscribe_InsertPlan $custid,136,6,11,"$today"};

$sth2 = $dbh->prepare($exec);
$sth2->execute || warn $sth2->errstr;

#-----------------------------------------------------------------------
# Find New Plan Id

$sql3 = <<_ENDSQL;
SELECT Plans.PlanID, Plans.CustomerID, Plans.PlanInfoID, Plans.Closed
FROM Plans
WHERE Plans.CustomerID=$custid AND Plans.PlanInfoID=136 AND Plans.Closed = 0
_ENDSQL

$sth3 = $dbh->prepare($sql3);
$sth3->execute || warn $sth3->errstr;

while (@detail = $sth3->fetchrow_array) {
        $planid = $detail[0];
        $custid2 = $detail[1];
        $planinfoid = $detail[2];
}
        print "PlanID  :  $planid\n";
        print "CustID  :  $custid2\n";
        print "PlanInfo:  $planinfoid\n";

#--------------------------------------------------------------------------
#Set the next billing date

$sql4 = <<_ENDSQL;
INSERT INTO PlansBillState (PlanID, UnitTypeID, LastBillDate, NextBillDate)
VALUES ($planid, 2, "$today", "07/01/2001")
_ENDSQL

$sth4 = $dbh->prepare($sql4);
$sth4->execute || warn $sth4->errstr;

#--------------------------------------------------------------------------
# Add a email login to virus scan table

$exec5 = qq{ Exec Subscribe_InsertLogins $planid, "$popname", "$password"};

$sth5 = $dbh->prepare($exec5);
$sth5->execute || warn $sth5->errstr;

#---------------------------------------------------------------------------
# Add Debit to account

$extracharge = ($charge * $duration) * $tax;

$exec6 = qq{ Exec Bill_AddDebit $planid,2,"$today",$extracharge,"EMail Virus
Scanning","$thismonth"

$sth6 = $dbh->prepare($exec6);
$sth6->execute || warn $sth6->errstr;

$dbh->disconnect || print "$DBI::errstr  $DBI::err\n";

Reply via email to