The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Passing parameters form unix to Oracle procedure rajasekharamy Shell Programming and Scripting 0 04-12-2007 09:24 AM
passing oracle parameters back to Shell satnamx Shell Programming and Scripting 4 01-16-2007 09:59 AM
Shell arrays in oracle stored procedure superprogrammer Shell Programming and Scripting 6 06-09-2005 07:36 PM
CGI passing arrays/hashes to another CGI script WIntellect Shell Programming and Scripting 2 01-13-2003 11:22 AM
Passing arrays to oracle from unix krishnasai Shell Programming and Scripting 7 08-12-2002 08:01 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-04-2006
satnamx satnamx is offline
Registered User
  
 

Join Date: Mar 2006
Posts: 34
Red face Passing arrays to oracle from unix

Hi all...

Im looking to pass the contents of a simple file to Oracle so that it can be stored in a database table.

The best way i can think of to avoid overhead is to loop through the contents of the file and store the data in a bash array. then the array can be passed to SQL Plus where Oracle can loop through the array and write the data away.

Is this a good way of doing it? if it is...does anyone have an exmple of how to pass an array from the bash shell to oracle

eg simple file called name.txt that contains the following..
tom
dick
harry

any help on this would be reatly appreciated?

This can be done by looping through lines in the file and for each line open up an oracle connection to write the data away eg but tis is expensive performance wise.

loop through file contents
"insert into table values variable1, variable2 ect| sqlplus -s scott/tiger
  #2 (permalink)  
Old 04-04-2006
vgersh99's Avatar
vgersh99 vgersh99 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,131
look into Oracle 'sqlldr'
  #3 (permalink)  
Old 04-04-2006
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,813
sqlldr is the best choice - vgersh99 is right on top of that.

Otherwise learn about the UTL_FILE package. And learn some PL/SQL.

Sometimes I've used an editor to turn a small flat file into several dozen insert statements, when the data is in columns and my editor supports macros. Turn

Code:
John Doe USA
-- into 
insert into mytable values ( 'John', 'Doe', 'USA');
............
commit;


Last edited by vgersh99; 04-05-2006 at 10:08 AM..
  #4 (permalink)  
Old 04-05-2006
satnamx satnamx is offline
Registered User
  
 

Join Date: Mar 2006
Posts: 34
Cant use sql loader or UTL File

Hi Guys, thanks for the sugesstion but i am already using SQL loader to load the contents of a csv file into Oracle and I can't use UTL FIle as That can only be used to manipulate files located on the same server as the database. I am working with files on the applications server which is different to the database server in our environment.

The file contents I want to load into Oracle is actually the LOG file produced by SQL Loader and this file is not of any particulat format hence the use of arrays to pass it to Oracle in 1 go.

It would be good to have an example of passing a bash array into oracle as reference... pretty pleaseeeee
  #5 (permalink)  
Old 04-05-2006
satnamx satnamx is offline
Registered User
  
 

Join Date: Mar 2006
Posts: 34
passing shell array to oracle???????

Dosnt anyone have an example of how to pass a Bash array to to Oracle??
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:54 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0