How to get result from both of these modules?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to get result from both of these modules?
# 1  
Old 04-28-2013
How to get result from both of these modules?

Hallo All unix Guru's

I have written a small (static) pl/sql function which is inserting data into database. It is as follows:

Code:
sqlplus $CONNECT <<-EOF
        DECLARE
        Counter integer :=1;
        BEGIN
        WHILE Counter <= ${no_of_files} LOOP
        INSERT INTO stuck_files(COL_DATE,SER_NAME,TYPE_FILE,FILENAME,FILE_STATUS) VALUES (sysdate,'pqrs','pqrs','pqrs','pqrs');
        Counter := Counter + 1;
        END LOOP;
        END;
        /
        commit;
        exit;
        EOF

However the above "insert" needs to be more of dynamic in nature, as such you can see that we want to insert data depending upon the variable value ${no_of_files}.

Now let me show you another module which is giving me the file(s)names which I want to insert.

Code:
N=0
for i in $(find . -path \*/waiting/* -type f -not -name "SS*" -mmin +120 -print) ; do
   
      testarray[$N]="$i"
      echo "$i"     
       
  let "N= $N + 1"
done

Sample Output from above command is as follows:
Code:
/d1/d2/d3/d4/waiting/abcd.txt
/d1/d2/d31/d42/waiting/pqrs.txt
/d1/d2/d32/d43/waiting/xyz.txt

Now the data insert which is given in the above pl/sql block has directly to do with this output. It going to be dynamic in nature.

Let us come back to mapping of how we need to insert data based on this output. I will go through the first insert.2 insert and 3rd insert so you would get an idea of design.
But these are very dynamic, meaning the insert depends on the output produced but yes the directory structure would remain same.
Code:
COL_DATE,SER_NAME,TYPE_FILE,FILEFILENAME,FILE_STATUS
sysdate,d3,d4,abcd.txt,waiting
sysdate,d31,d42,pqrs.txt,waiting
sysdate,d32,d3,xyz.txt,waiting

I believe this can definitely be implemented with help of magic like awk or anything but not able to implement it.

Any ideas/help would be greatly appreciated.
# 2  
Old 04-28-2013
I have 2 suggestions:
  • Create a PL/SQL procedure that accepts argument. Use a while loop to read input and pass them as argument to PL/SQL procedure.
  • Create a SQL Loader control file and load input into your table using sqlldr.
I prefer 2nd method because that is going to be really fast thus much efficient.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to compare the current result with previous line result.?

Hi Gurus, I have requirement to compare current result with previous reuslt. The sample case is below. 1 job1 1 1 job2 2 1 job3 3 2 job_a1 1 2 job_a2 2 2 job_a3 3 3 job_b1 1 3 job_b2 2 for above sample file, GID is group ID, for input line, the job run... (1 Reply)
Discussion started by: ken6503
1 Replies

2. Shell Programming and Scripting

how to create custom modules in perl and how to import all modules with single command?

I have some custom functions which i want to use in perl Scripting all time. i want to How to create modules in perl and how to import them. Also if i create 15 modules and i want to > import all at once then how can i import? (0 Replies)
Discussion started by: Navrattan Bansa
0 Replies

3. Linux

Which modules get installed with modules_install

I'm trying to build a 2.6.18 kernel for XEN (level 0), and I need to make an initrd image that will utilize our HP's raid/scsi driver (cciss.o). The driver is being built and I can see it in drivers/block/cciss.o. But when I do "make modules_install", this module is not copied into the... (2 Replies)
Discussion started by: otheus
2 Replies

4. UNIX for Dummies Questions & Answers

installing perl modules

I resulted to using /usr/sfw/bin/gmake to install my perl modules until i ran into a problem installing perl/Tk Tk-804.028 gmake: Entering directory `/export/home/Tk-804.028/pod' Sorry no HTML building yet gmake: Leaving directory `/export/home/Tk-804.028/pod' I dont unstand what the error... (2 Replies)
Discussion started by: jameskay
2 Replies

5. UNIX for Dummies Questions & Answers

display the result of wc -l with words before and after the result

hello showrev -p | wc -l returns: 381 What to do in case I want to have this output: number of lines returned by showrev -p is: 381 thx (3 Replies)
Discussion started by: melanie_pfefer
3 Replies

6. Shell Programming and Scripting

Outputting formatted Result log file from old 30000 lines result log<help required>

Well I have a 3000 lines result log file that contains all the machine data when it does the testing... It has 3 different section that i am intrsted in 1) starting with "20071126 11:11:11 Machine Header 1" 1000 lines... "End machine header 1" 2) starting with "20071126 12:12:12 Machine... (5 Replies)
Discussion started by: vikas.iet
5 Replies

7. UNIX for Dummies Questions & Answers

modules under bsd

Hello I know that I can load or unload kernel modules (/sbin/modload or /sbin/modunload) but how can I check what of modules are now loaded to my kernel? I heard that I can do it by /sbin/modstat but I haven't file like this in my system... Please help me. Have a nice day (2 Replies)
Discussion started by: pgas
2 Replies

8. UNIX for Advanced & Expert Users

Compilng Modules

Hi all Can anyone tell me if it is possible to compile modules individually without having to recompile the whole kernel? I have recently compiled a new kernel but forgot to compile in lp.o which would allow me to print. I can see lp.c in /usr/src/linux/kernel/drivers/char sometimes in these... (1 Reply)
Discussion started by: silvaman
1 Replies

9. UNIX for Dummies Questions & Answers

/etc/modules/conf

RedHat 7.1 I get /etc/modules.conf is more recent than /lib/modules/2.4.2-2/modules.dep This is currently running on a Dell Latitude CPi Laptop. (2 Replies)
Discussion started by: jblank1234
2 Replies
Login or Register to Ask a Question