I'm not able to reproduce your results.

Does ctrl-C kill the perl process and leave the select running, or does it fail to 
kill the perl?

Does ctrl-C work if you change any of the following?
        remove sleep()
        remove distinct from the query
        replace dump_results() with bind_columns() and fetch()
        

-----Original Message-----
From: Khamneian, Mahtaj [mailto:[EMAIL PROTECTED]
Sent: Tuesday, December 16, 2003 11:36 AM
To: [EMAIL PROTECTED]
Subject: RE: Signal Handling


Thanks for the reply.
I have tried a slight variation of what you've suggested, but it seems, the db 
operation is not cancelled as a result of hitting 
CTRL-C-- I have to kill the process manually to stop the program.
Here's a snippet of the program:
...
sub kill_me{my $key = shift; die "\n\n\tKilled:$key\n\n";}
$SIG{INT} = \&kill_me;

DBI->trace (0);

# connect to target db
my $dbh = DBI->connect ("dbi:Oracle:$sid", $user, $password)
        or die "Can't connect to database: $DBI::errstr\n";

my $sth = $dbh->prepare( "select distinct sid, status, client_info, b.name, b.emailid 
from
v\$session, ps_um_employees b where 
substr(client_info,1,(instr(client_info,',')-1))=b.mang
led_sso (+) and status='ACTIVE'" );

while (1) {
   $sth->execute();
   my $rows = $sth->dump_results();

   sleep(5);
}

$dbh->disconnect;

exit 0;


> -----Original Message-----
> From: Helck, Timothy [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, December 16, 2003 7:51 AM
> To: Khamneian, Mahtaj; [EMAIL PROTECTED]
> Subject: RE: Signal Handling
> 
> 
> I'm not sure if this is what you have in mind:
> 
> sub kill_me{my $key = shift; die "\n\n\tKilled:$key\n\n";}
> $SIG{INT} = \&kill_me;
> 
> This will kill the Perl process and (I think) any child processes.
> 
> 
> -----Original Message-----
> From: Khamneian, Mahtaj [mailto:[EMAIL PROTECTED]
> Sent: Monday, December 15, 2003 4:17 PM
> To: [EMAIL PROTECTED]
> Subject: Signal Handling
> 
> 
> Has anyone been able to successfully implement CTRL-C signal 
> handling in Perl DBI?
> If so, I'd appreciate an example.
> 
> -------------------------------------
> Mahtaj Khamneian                                     
> University of Missouri - ASP       Phone : (573) 884-2281
> 1805 East Walnut                          Fax     : (573) 
> 884-3070                                  
> Columbia, MO 65201-6425          [EMAIL PROTECTED]
> I wish I were able to create a program that could ping my mind.
> I would then load it into the creation's/nature's server, for which
> no root access is needed, and invoke it via cron at spontaneous
> intervals.
> 
> 

Reply via email to