Oracle Function Needed


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Oracle Function Needed
# 1  
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
# 2  
Old 01-22-2009
hi
any updates?
# 3  
Old 01-22-2009
What does the input look like? What should the output be?
If you are going to read files, you have to make sure that you have permissions to read file systems from Oracle - which only a DBA can set up.

What have you tried so far?

I'd recommend asking people on an Oracle specific forum for the answer to this.
# 4  
Old 01-22-2009
Oracle has a DBA-specified startup parameter called utl_file_dir which tells Oracle to use that directory only for file input/output for packages (functions, triggers, etc) running inside that instance of Oracle.

Plus as SFNYC, mentioned it is impossible for someone here to port the perl code based the above to an Oracle db function. It is a fairly major deal in terms of schema information, input output required, etc. You need an Oracle forum.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

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 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

7. 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

8. 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

9. 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
Login or Register to Ask a Question

Featured Tech Videos