Jacob Elder wrote:

>On Tue, Apr 09, 2002 at 11:13:09AM +0100, Martin Harriss wrote:
>
>>I am using Embperl on an intranet system to perform complex database 
>>searches and display the results.
>>
>>My problem is that, depending on the parameters given by the user, some 
>>searches can take some time - returning thousands of rows, and there is a 
>>danger that the user will hit the stop button, execute the Back command or 
>>even close the browser session altogether.  If this happens at the wrong 
>>time, an oracle connection could have been made, but no SQL sent to it, 
>>leaving an Oracle process hanging there.
>>
>>I need to be able to trap these browser events, and I can then call a 
>>cleanup routine to close any database connections.  I can use the 
>>Javascript onUnload event, I can't figure how to commmuncate with the Perl 
>>process.
>>
>
>I don't remember where I saw this, but I think it might be what you're
>looking for.
>
>while ($dbh->fetch) {
>
>       # format, print, etc.
>
>       last if $r->connection->aborted;
>}
>$dbh->disconnect;
>

Remember that if you're using Apache::DBI, your database connection will 
be persistant anyway, so that's not a total waste :)  The above code's 
still a good idea (although the $dbh->disconnect will be silently 
ignored under Apache::DBI) as it will still free the process (or thread 
soon :)) which is dealing with the current response, which would 
otherwise still have lots of work to do for a client who's no longer 
interested.

  Issac

Reply via email to