Sponsored Content
Full Discussion: Oracle Function Needed
Top Forums Shell Programming and Scripting Oracle Function Needed Post 302278326 by shary on Tuesday 20th of January 2009 03:05:06 AM
Old 01-20-2009
Oracle Function Needed

Dear Experts,
Please find below the script in perl and can any body convert this script exactly in to oracle 9i fiunction which will return the required result same as perl.

Code:
#!/usr/bin/perl
$nof=@ARGV;


@var2 = ();

for($n=0; $n<$nof; $n++)
{
        $filename = @ARGV[$n];
        open (input, "<$filename");
        while(<input>)
        {
                chomp;
                @var3 = split(',',$_);
                $cnt_var3 = @var3;
                if(@var3[2] eq '501')
                {
                        if($cnt_var3 eq '214')
                        {
                                for($i=0,$j=27; $i<15; $i++)
                                {
                                        @var2[$i]+=@var3[$j];
                                        $j = $j + 13;
                                }
                        }
                        else
                        {
                                for($i=0,$j=27; $i<15; )
                                {
                                        @var2[$i]+=@var3[$j];
                                        $k = $j + 5;
                                        if(@var3[$k] eq '|')
                                        {
                                                $j = $j + 11;
                                        }
                                        else
                                        {
                                                $j = $j + 13;
                                                $i++;
                                        }
                                }
                        }
                }
        }
        close (input);
}

$sum = 0;
for($i=0; $i<15; $i++)
{
        print "@var2[$i],";
        $sum+=@var2[$i];
}
print "$sum\n"

Thanks

Last edited by Franklin52; 01-20-2009 at 03:23 PM.. Reason: adding code tags
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help needed in function calling in a script

:confused:Hi , I have a script as shown below: rpttxt() { name="$*" awk '/'"${name}"'/ {print $2 $3"=" $4}' file.txt } xx = rpttxt "COL_HEAD_1" awk 'BEGIN {printf("%36s \n ","'"$xx"'")}' rpttxt() is a function..I want to store the final result of this function in... (3 Replies)
Discussion started by: jisha
3 Replies

2. Shell Programming and Scripting

Help needed to Keep calling a function after every 5 seconds.

Hey guys.! Need some help.I want to write a script , which should be continuosly running and should keep calling a function after every say 5 or 10 seconds. I am done with almost all part of it, but figuring out how to keep the script continuosly running and how to keep calling a function after... (11 Replies)
Discussion started by: nua7
11 Replies

3. Shell Programming and Scripting

help needed at awk function

hi, I am new to scripting and need your help to debug . Here is my goal, I need to collect text,validate it and say if there is any error .below is the code validate_fn() { awk ' .... END { if(condition) return 0 ... (2 Replies)
Discussion started by: rider29
2 Replies

4. Shell Programming and Scripting

Help needed for understanding a function

There is a function called start: start() { echo -n $"Sending Startup Email: " echo "${RESTARTBODY}" | mutt -s "${RESTARTSUBJECT}" ${EMAIL} RETVAL=$? if ; then touch ${LOCKFILE} success else failure fi echo return ${RETVAL} } Can anyone explain what the bold part of the... (3 Replies)
Discussion started by: proactiveaditya
3 Replies

5. Shell Programming and Scripting

getting return value from oracle function

So, in Oracle (11gR2) on aix I have a function like: CREATE OR REPLACE function COMMON.t2(var1 in varchar2, vari in number,var2 in out number) return number as begin insert into korisnik_temp(kor_inicia, kor_opisno) values(1, var1); var2:=0; return var2; exception when... (12 Replies)
Discussion started by: bongo
12 Replies

6. Shell Programming and Scripting

Help needed for shell scripting for oracle.

Hi, Please see contains both files created for automating the data from oracle through shell. 1)a_p.ksh #!/bin/ksh LOG=/home/A_P.log MESSAGE=/home/MESSAGE_A_P.txt mail_list=/home/AP_MAIL_LIST.txt data=/home/spooled_A_P.log echo "`date` Starting execution for A_P COUNT" > $LOG ... (2 Replies)
Discussion started by: fidelis
2 Replies

7. Shell Programming and Scripting

Help needed in retreiving records from Oracle

Hello, I am new to UNIX. My Requirement: Need to connect to Oracle database from UNIX and execute an SELECT statement and store the records in a flatfile of Comma delimiter. What I have Succeeded: I was able to connect to Oracle from UNIX. Problem: I cannot fetch multiple... (3 Replies)
Discussion started by: arunvasu2
3 Replies

8. Solaris

Help with C function and Oracle

Hi, I am calling database package from Pro*C program. It is giving me the error ORA-01426 : numeric overflow. my package function is having all arguments with char or varchar variable. int retval := pkg1.func1(arg1 varchar(3), arg2 char(8)); In this call only numeric variable is... (7 Replies)
Discussion started by: user270885
7 Replies

9. Shell Programming and Scripting

Oracle pmon output needed

$ ps -ef | grep pmon | grep -v grep | awk '{ print $8 }' | cut -d '_' -f3 abc1 abc2 abc3 abc4 abc5 +ASM1 Please use code tags from above output i am looking exclude +ASM output and restout put is fine , also when i select any output and if is invalid from above output, shell script... (12 Replies)
Discussion started by: amar1208
12 Replies
TAP::Parser::SourceHandler::Perl(3pm)			 Perl Programmers Reference Guide		     TAP::Parser::SourceHandler::Perl(3pm)

NAME
TAP::Parser::SourceHandler::Perl - Stream TAP from a Perl executable VERSION
Version 3.23 SYNOPSIS
use TAP::Parser::Source; use TAP::Parser::SourceHandler::Perl; my $source = TAP::Parser::Source->new->raw( 'script.pl' ); $source->assemble_meta; my $class = 'TAP::Parser::SourceHandler::Perl'; my $vote = $class->can_handle( $source ); my $iter = $class->make_iterator( $source ); DESCRIPTION
This is a Perl TAP::Parser::SourceHandler - it has 2 jobs: 1. Figure out if the TAP::Parser::Source it's given is actually a Perl script ("can_handle"). 2. Creates an iterator for Perl sources ("make_iterator"). Unless you're writing a plugin or subclassing TAP::Parser, you probably won't need to use this module directly. METHODS
Class Methods "can_handle" my $vote = $class->can_handle( $source ); Only votes if $source looks like a file. Casts the following votes: 0.9 if it has a shebang ala "#!...perl" 0.75 if it has any shebang 0.8 if it's a .t file 0.9 if it's a .pl file 0.75 if it's in a 't' directory 0.25 by default (backwards compat) "make_iterator" my $iterator = $class->make_iterator( $source ); Constructs & returns a new TAP::Parser::Iterator::Process for the source. Assumes "$source->raw" contains a reference to the perl script. "croak"s if the file could not be found. The command to run is built as follows: $perl @switches $perl_script @test_args The perl command to use is determined by "get_perl". The command generated is guaranteed to preserve: PERL5LIB PERL5OPT Taint Mode, if set in the script's shebang Note: the command generated will not respect any shebang line defined in your Perl script. This is only a problem if you have compiled a custom version of Perl or if you want to use a specific version of Perl for one test and a different version for another, for example: #!/path/to/a/custom_perl --some --args #!/usr/local/perl-5.6/bin/perl -w Currently you need to write a plugin to get around this. "get_taint" Decode any taint switches from a Perl shebang line. # $taint will be 't' my $taint = TAP::Parser::SourceHandler::Perl->get_taint( '#!/usr/bin/perl -t' ); # $untaint will be undefined my $untaint = TAP::Parser::SourceHandler::Perl->get_taint( '#!/usr/bin/perl' ); "get_perl" Gets the version of Perl currently running the test suite. SUBCLASSING
Please see "SUBCLASSING" in TAP::Parser for a subclassing overview. Example package MyPerlSourceHandler; use strict; use vars '@ISA'; use TAP::Parser::SourceHandler::Perl; @ISA = qw( TAP::Parser::SourceHandler::Perl ); # use the version of perl from the shebang line in the test file sub get_perl { my $self = shift; if (my $shebang = $self->shebang( $self->{file} )) { $shebang =~ /^#!(.*perl.*?)(?:(?:s)|(?:$))/; return $1 if $1; } return $self->SUPER::get_perl(@_); } SEE ALSO
TAP::Object, TAP::Parser, TAP::Parser::IteratorFactory, TAP::Parser::SourceHandler, TAP::Parser::SourceHandler::Executable, TAP::Parser::SourceHandler::File, TAP::Parser::SourceHandler::Handle, TAP::Parser::SourceHandler::RawTAP perl v5.16.2 2012-10-25 TAP::Parser::SourceHandler::Perl(3pm)
All times are GMT -4. The time now is 01:19 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy