[prev in list] [next in list] [prev in thread] [next in thread] 

List:       perl-beginners
Subject:    Re: Interrupt Handling
From:       Gopal Karunakar <gk.kalipurayath () gmail ! com>
Date:       2010-09-23 1:14:12
Message-ID: AANLkTi=MZDZcU-WuM2jojbTRnJA7JkiE3NirNcobxxBa () mail ! gmail ! com
[Download RAW message or body]


Hi,

         Thanks a lot for posting hte most efficient way to remove leading
and trailing spaces. And yes you are right the retval will always be zero. I
am guessing it was supposed to capture sql code errors but it wont. It will
capture only sqlplus errors.
         I havent pasted the whole pl/sql code in here, but it's valid and
executing fine. I just needed to get this behavior in this sub to be
working. As Charles DeRykus mentioned above in the discussion, it may be a
sqlplus related quirk or bug, Haven't found anything online on it though.


Thanks & Regards,

GK

On 23 September 2010 03:32, John W. Krahn <jwkrahn@shaw.ca> wrote:

> [ Please do not top-post.  TIA ]
>
>
> Gopal Karunakar wrote:
>
>> Hi,
>>
>
> Hello,
>
>
>     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]);
>>
>
> That is usually written as:
>
>    my ( $option, $sourceID, $targetID ) = @_;
>
>
>
>     $option         =~ s/^\s*(\S*(?:\s+\S+)*)\s*$/$1/;
>>    $sourceID       =~ s/^\s*(\S*(?:\s+\S+)*)\s*$/$1/;
>>    $targetID       =~ s/^\s*(\S*(?:\s+\S+)*)\s*$/$1/;
>>
>
> That is a very inefficient and non-standard way to remove leading and
> trailing whitespace:
>
>      s/^\s+//, s/\s+$// for $option, $sourceID, $targetID;
>
>
>
>     my $retval;
>>
>>    $retval = `/$ENV{'ORACLE_HOME'}/bin/sqlplus -s  $QUERY_STRING<<  EOF>>
>> $db_log
>>
>
> $retval gets the standard output from /$ENV{ORACLE_HOME}/bin/sqlplus but
> you are redirecting the standard output to >>$db_log so $retval should
> always be empty.
>
>
>
>     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) ;
>>
>
> Is that a valid SQL statement?  I know that that is not valid in Perl or
> the shell.
>
>
>
>          DBMS_OUTPUT.PUT_LINE (o_ret_message);
>>         DBMS_OUTPUT.PUT_LINE (DBMS_UTILITY.FORMAT_ERROR_BACKTRACE);
>>
>>
>>         ROLLBACK;
>>
>>         END;
>> /
>>
>> EOF` ;
>>
>> return $retval;
>> }
>>
>
>
>
> John
> --
> Any intelligent fool can make things bigger and
> more complex... It takes a touch of genius -
> and a lot of courage to move in the opposite
> direction.                   -- Albert Einstein
>
> --
> To unsubscribe, e-mail: beginners-unsubscribe@perl.org
> For additional commands, e-mail: beginners-help@perl.org
> http://learn.perl.org/
>
>
>


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic