The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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
Connecting to oracle database from shell script satyakiran Shell Programming and Scripting 8 07-03-2009 03:22 PM
How to insert data into MYSql database from a text file shirleyeow Shell Programming and Scripting 4 01-11-2008 05:00 AM
Shell Script to Load data into the database using a .csv file and .ctl file Csmani Shell Programming and Scripting 3 05-24-2006 08:09 AM
how to insert data in database based on text file? forevercalz Shell Programming and Scripting 9 12-20-2005 11:40 PM
unix script to export data from csv file to oracle database vinayagan Shell Programming and Scripting 3 07-20-2005 04:16 AM

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

Join Date: Mar 2007
Posts: 2
Need Shell Script to upload data from Text file to Oracle database

Hi
Does any one have any idea on uploading the data using Unix Shell script from text file to Oracle database.
Requirement:-
1. Need to connect to Oracle database from Unix Shell script.
2. Need to pick Text file from some location on Unix Box.
3. Need to upload the data from text file to some table in Oracle Database.


Any similar scripts matching above requirement is also highly appreciated.
Or any one have any idea on shell scripts available on net.
Advance Thanks
JC
  #2 (permalink)  
Old 03-21-2007
dennis.jacob dennis.jacob is offline Forum Advisor  
dj -------
  
 

Join Date: Feb 2007
Location: Singapore/Bangalore/Cochin
Posts: 558
Hi,

You can use sqlldr command directly from unix to do this.
Syntax is like this :

sqlldr control=ctlFile log=logFile bad=badFile
  #3 (permalink)  
Old 03-21-2007
dennis.jacob dennis.jacob is offline Forum Advisor  
dj -------
  
 

Join Date: Feb 2007
Location: Singapore/Bangalore/Cochin
Posts: 558
Quote:
Originally Posted by jacoden
Hi,

You can use sqlldr command directly from unix to do this.
Syntax is like this :

sqlldr control=ctlFile log=logFile bad=badFile
Below one is a good link explaining creating the control, data , load, bad log files..

Read this
  #4 (permalink)  
Old 03-22-2007
chandrashekharj chandrashekharj is offline
Registered User
  
 

Join Date: Mar 2007
Posts: 2
Thanks a lot jacoden !!!
Regards
JC
  #5 (permalink)  
Old 03-25-2007
ynixon ynixon is offline
Registered User
  
 

Join Date: Mar 2007
Posts: 57
a complete code

Example, here is a utility that will take the output from Linux vmstat utility and insert the output into an Oracle table:

PATH=$ORACLE_HOME/bin:$PATH
export PATH
SERVER_NAME=`uname -a|awk '{print $2}'`
typeset -u SERVER_NAME
export SERVER_NAME

# sample every five minutes (300 seconds) . . . .
SAMPLE_TIME=300

while true
do
vmstat ${SAMPLE_TIME} 2 > /tmp/msg$$


# run vmstat and direct the output into the Oracle table . . .
cat /tmp/msg$$|sed 1,3d | awk '{ printf("%s %s %s %s %s %s\n", $1, $8, $9,
14, $15, $16) }' | while read RUNQUE PAGE_IN PAGE_OUT USER_CPU SYSTEM_CPU
IDLE_CPU
do

$ORACLE_HOME/bin/sqlplus -s perfstat/perfstat@testsys1<<EOF
insert into perfstat.stats\$vmstat
values (
sysdate,
$SAMPLE_TIME,
'$SERVER_NAME',
$RUNQUE,
$PAGE_IN,
$PAGE_OUT,
$USER_CPU,
$SYSTEM_CPU,
$IDLE_CPU,
0
);
EXIT
EOF
done
done

rm /tmp/msg$$

(taken from this site)
  #6 (permalink)  
Old 03-26-2007
dennis.jacob dennis.jacob is offline Forum Advisor  
dj -------
  
 

Join Date: Feb 2007
Location: Singapore/Bangalore/Cochin
Posts: 558
Quote:
Originally Posted by ynixon
Example, here is a utility that will take the output from Linux vmstat utility and insert the output into an Oracle table:

PATH=$ORACLE_HOME/bin:$PATH
export PATH
SERVER_NAME=`uname -a|awk '{print $2}'`
typeset -u SERVER_NAME
export SERVER_NAME

# sample every five minutes (300 seconds) . . . .
SAMPLE_TIME=300

while true
do
vmstat ${SAMPLE_TIME} 2 > /tmp/msg$$


# run vmstat and direct the output into the Oracle table . . .
cat /tmp/msg$$|sed 1,3d | awk '{ printf("%s %s %s %s %s %s\n", $1, $8, $9,
14, $15, $16) }' | while read RUNQUE PAGE_IN PAGE_OUT USER_CPU SYSTEM_CPU
IDLE_CPU
do

$ORACLE_HOME/bin/sqlplus -s perfstat/perfstat@testsys1<<EOF
insert into perfstat.stats\$vmstat
values (
sysdate,
$SAMPLE_TIME,
'$SERVER_NAME',
$RUNQUE,
$PAGE_IN,
$PAGE_OUT,
$USER_CPU,
$SYSTEM_CPU,
$IDLE_CPU,
0
);
EXIT
EOF
done
done

rm /tmp/msg$$

(taken from this site)
"INSERT" will not be effective if there are thousands of records to be loaded...

Last edited by dennis.jacob; 03-26-2007 at 02:27 AM..
  #7 (permalink)  
Old 03-26-2007
ynixon ynixon is offline
Registered User
  
 

Join Date: Mar 2007
Posts: 57
in that case...

use sqlloader, external table or pro*c
Sponsored Links
Closed Thread

Bookmarks

Tags
linux

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 04:24 PM.


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