in reply to DBI Prematurely Disconnecting
The only error that i've ever encountered with this is MicrosoftODBC Sql Server DriverInvalid cursor state (SQL-24000)(DBD: dbd_describe/SQLNumResultsCols err=-1) I can reproduce this by using a stored procedure that includes RAISERROR('my test progress message',1,10) WITH NOWAIT I use that to help notify me of progress as a long running procedure executes from SSMS. I understand if maybe it disconnects automatically when receiving this message although a low code such as 10 is considered informational and noncritical as far as sql server goes. Of course I can simply remove these and it works but i'd like to keep them if possible. My biggest problem is that I get the premature termination behavior if a SELECT returns results before the rest of the procedure is finished. In my case I return a list of records I will update within the procedure and then it uses While loop to do the updates. Again if I use the stored procedure directly in Sql Server Management Studio, it works perfectly. From within perl, as soon as it receives the results from the first select, the server only has enough time to update 10-20 records and then it is terminated by something in perl with no errors. 100% reproducible but it has to be 1000+ recordsmy $dbh11 = DBI->connect("dbi:ODBC:driver={SQL Server};Server=$dbserve +r;database=$DBName;",$uid,$pwd, {AutoCommit => 1, RaiseError=>1, Hand +leError=>\&HandleDBError}) or die "Can't connect to $dbserver/$DBName: $DBI::errstr"; DBI->trace(9,"dbiDOtrace.log"); my $sthExec = $dbh11->do(qq/exec spMyProcedure/) or die "error pre +paring execute transfers sql"; $dbh11->disconnect(); print LOGFILE "Done exec\n";
If I remove the initial select, all records get updated. If I include the select, only a random number are able to finish by the time perl terminates it. Number is different everytime depending on the execution time between client and server but averages only about 10-20 updates.SELECT id, col2, col3 from LargeTable DECLARE @i int SET @i=1 While @i<1000 BEGIN UPDATE LargeTable SET col2=getdate() WHERE id=@i END
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: DBI Prematurely Disconnecting
by mje (Curate) on Oct 09, 2013 at 16:03 UTC | |
by perldc (Initiate) on Oct 09, 2013 at 17:29 UTC | |
by mje (Curate) on Oct 09, 2013 at 17:57 UTC | |
by perldc (Initiate) on Oct 14, 2013 at 15:28 UTC | |
by mje (Curate) on Oct 14, 2013 at 17:20 UTC | |
by perldc (Initiate) on Oct 09, 2013 at 17:43 UTC | |
by mje (Curate) on Oct 09, 2013 at 17:52 UTC | |
by mpeppler (Vicar) on Oct 11, 2013 at 05:13 UTC | |
by perldc (Initiate) on Oct 14, 2013 at 15:40 UTC |