Hi,

   Here's the code pasted below. The sub basically executed an anonymous
pl/sql block (which is executing fine). I want to make sure that the user
will not be able to a ctrl-c and exit at the stage where the sql statements
are getting executed.

   I tried declaring it as local but even then its hanging when i give the
interrupt.


sub CopyData
{
  local $SIG{'INT'} = 'IGNORE';

  ($option, $sourceID, $targetID, ) = ($_[0], $_[1], $_[2]);

   $option         =~ s/^\s*(\S*(?:\s+\S+)*)\s*$/$1/;
   $sourceID       =~ s/^\s*(\S*(?:\s+\S+)*)\s*$/$1/;
   $targetID       =~ s/^\s*(\S*(?:\s+\S+)*)\s*$/$1/;

   my $retval;

   $retval = `/$ENV{'ORACLE_HOME'}/bin/sqlplus -s  $QUERY_STRING << EOF >>
$db_log
   WHENEVER OSERROR EXIT 5 ROLLBACK;
   WHENEVER SQLERROR EXIT 10 ROLLBACK;
   SET SERVEROUTPUT ON SIZE 1000000;
   SET FEEDBACK OFF;
   set pagesize 0;
   set linesize 150;

   DECLARE

    ........................

    ............

             COMMIT;

        EXCEPTION

          WHEN OTHERS
           THEN


        o_ret_message :=  'Exception occured -' || ' Module Name:' || g_msg
|| CHR(10) ||
                          'Error Code: ' || SQLCODE || CHR(10) ||
                          'Error Message: ' || SUBSTR(sqlerrm,1,2000) ;
        DBMS_OUTPUT.PUT_LINE (o_ret_message);
        DBMS_OUTPUT.PUT_LINE (DBMS_UTILITY.FORMAT_ERROR_BACKTRACE);


        ROLLBACK;

        END;
/

EOF` ;

return $retval;
}


Regards,

GK.


On 22 September 2010 22:57, C.DeRykus <dery...@gmail.com> wrote:

> On Sep 22, 6:53 am, gk.kalipuray...@gmail.com (Gopal Karunakar) wrote:
>
> >         I used the $SIG{'INT'} = 'IGNORE'; in a sub in my script so that
> the
> > script while executing the particular sub will ignore the ctrl-c. And I
> gave
> > $SIG{'INT'} = 'DEFAULT'; at the end of the sub to reset the behavior back
> to
> > normal.
>
> Presuming your signal setting is the default on entry to
> the sub,  you can just use local to temporarily set the
> interrupt:
>
>   sub foo { local $SIG{INT} = 'IGNORE'; ... }
>
> The interrupt signal will be ignored for the scope of
> the sub. When the sub ends, the interrupt setting
> returns to its prior value.
>
> > But when i give the ctrl-c the process seems to be hanging and I
> > have to kill the process from the prompt. Is there any way to avoid
> getting
> > this behavior?? When i give the ctrl-C the script should just ignore it
> and
> > continue the process. I am on Sun Solaris box and using Perl version
> 5.8.7.
> >
>
> Are you sure there's only one exit point from the sub... ?
> That's a possible scenario which could bypass your
> $SIG{'INT'} = 'DEFAULT' reset at the end of the sub.
> (BTW, that's another advantage to using 'local')
>
> Show of the code too.  You can just pull out some of
> the relevant lines to give everyone a better view of the
> crime scene.  It's much easier to spot what might be
> happening.
>
> --
> Charles DeRykus
>
>
> --
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
>
>
>

Reply via email to