Have you tried running this through the debugger to see where exactly the
problem is occurring.  Have you also tried running the stored proc in isql
(or what ever M$SQL calls it) to make sure the stored proc is OK?

The error message below indicates that your statement handle is still
active... you said you used finish() on this, right?  I don't know about
M$SQL, but in Sybase it is sometimes helpful to loop through the result
set completely (look in the DBD::Sybase perldoc for the code).

The small snippet of code you have looks like the syntax is correct, so
I'd look at the stored proc and then try to make sure that the statement
handle is not active by finishing it or making sure all the results have
been returned.

On Fri, 6 Apr 2001, Jamie Orzechowski wrote:

> same error
> 
> Name "main::charge" used only once: possible typo at ./test line 11.
> DBI::db=HASH(0x81ce7d8) trace level set to 9 in DBI 1.15-nothread
> -> disconnect for DBD::Sybase::db (DBI::db=HASH(0x81ce82c)~0x81ce7d8)
> DBI::db=HASH(0x81ce7d8)->disconnect invalidates 1 active statement handle
> (either destroy statement handles or call finish on them before
> disconnecting) at ./test line 25.
> syb_db_disconnect() -> ct_close()
> <- disconnect= 1 at ./test line 25.
> -> DESTROY for DBD::Sybase::db (DBI::db=HASH(0x81ce7d8)~INNER)
> <- DESTROY= undef during global destruction.
> ----------------------------------------------
> 
> $dbh = DBI->connect("dbi:Sybase:database=xxxxxxx", "xxxxxxxxx",
> "xxxxxxxxxxxxx");
> 
> $sql = <<_ENDSQL;
> Exec Subscribe_InsertPlan 13200,136,6,11,"04/06/2001"
> _ENDSQL
> 
> $sth = $dbh->prepare($sql);
> $sth->execute;
> $dbh->trace(9);
> $dbh->disconnect() or die("$DBI::errstr $DBI::err\n");
> 
> 
> ----- Original Message -----
> From: "Curt Russell Crandall" <[EMAIL PROTECTED]>
> To: "Jamie Orzechowski" <[EMAIL PROTECTED]>
> Cc: <[EMAIL PROTECTED]>
> Sent: Friday, April 06, 2001 2:37 PM
> Subject: Re: Script Hangs when executing ...
> 
> 
> > I don't know if this will help, but try changing
> >
> > $dbh->disconnect || print "$DBI::errstr $DBI::err\n";
> >
> > to
> >
> > $dbh->disconnect() or die("$DBI::errstr $DBI::err\n");
> >
> > I'm probably wrong, but if something is wrong with disconnect, but not
> > 'die'ing, you might be causing it to hang on the print.  Since disconnect
> > is at the very end of your script and a failure in disconnect probably
> > indicates something serious... I'd just let it die.
> >
> > On Fri, 6 Apr 2001, Jamie Orzechowski wrote:
> >
> > > 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