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
unix script for loading a data from a file into database grajesh_955 Shell Programming and Scripting 5 11-08-2008 11:49 PM
Shell script that reads from configuration file to get database dolo21taf Shell Programming and Scripting 1 04-15-2008 07:47 PM
Need Shell Script to upload data from Text file to Oracle database chandrashekharj Shell Programming and Scripting 6 03-26-2007 03:21 AM
Shell Script to clense junk data file rimss UNIX for Advanced & Expert Users 0 06-07-2006 12:16 AM
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 05-05-2006
Csmani Csmani is offline
Registered User
  
 

Join Date: May 2006
Posts: 2
Smile Shell Script to Load data into the database using a .csv file and .ctl file

Since i'm new to scripting i'm findind it difficult to code a script. The script has to be an executable with 2 paramters passed to it.The Parameters are
1. The Control file name(.ctl file)
2. The Data file name(.csv file)

Does anybody have an idea about it?
  #2 (permalink)  
Old 05-05-2006
encrypted's Avatar
encrypted encrypted is offline Forum Advisor  
Registered User
  
 

Join Date: Feb 2004
Location: Oslo, Norway
Posts: 219
Is this SQL Loader you are using to load data into oracle database?
  #3 (permalink)  
Old 05-05-2006
Csmani Csmani is offline
Registered User
  
 

Join Date: May 2006
Posts: 2
Yes I'm using SQL loader.I'm going to execute the shell script in the UNIX environment.I want to pass the control filename and the data filename as parameters while execution.
  #4 (permalink)  
Old 05-24-2006
encrypted's Avatar
encrypted encrypted is offline Forum Advisor  
Registered User
  
 

Join Date: Feb 2004
Location: Oslo, Norway
Posts: 219
Something on the lines of :

Code:
#!/bin/bash
if [ $# = 2 ]
then
    if [ $1 = " " -o $2 = " " ]
    then
        echo "Wrong or No arguments"
    else
        SOURCE_DIR=$HOME/Logdump
	LOG_DIR=$HOME/admin/log
	LOG_FILE=LoadSQL.log
        DATAFILE=$1
        TABLENAME=$2
        DST_FILE=$HOME/dump.ctl
        echo LOAD DATA > $DST_FILE
        echo INFILE "'"$SOURCE_DIR"/"$DATAFILE"'" >> $DST_FILE
        echo APPEND INTO TABLE $TABLENAME >> $DST_FILE
        echo FIELDS TERMINATED BY "','" OPTIONALLY ENCLOSED BY "'\"'" >>$DST_FILE
        echo TRAILING NULLCOLS >>$DST_FILE
        echo "(" >>$DST_FILE
        echo datestamp date '"Mon DD RRRR  HH:MIAM"',>>$DST_FILE
        echo request_file, >>$DST_FILE
        echo product_no, >>$DST_FILE
        echo card_no, >>$DST_FILE
        echo key_no, >>$DST_FILE
        echo message char"("1000")", >>$DST_FILE
        echo id sequence"("max,1")" >>$DST_FILE
        echo ")" >>$DST_FILE
        $HOME/admin/bin/.runme
        \rm dump.ctl
	echo "*****************************************************************" >> $LOG_DIR/$LOG_FILE 
	date '+DATE: %m/%d/%y TIME:%H:%M:%S' >> $LOG_DIR/$LOG_FILE
	echo $1 "Sucessfully Loaded into Database" >> $LOG_DIR/$LOG_FILE 
	echo "*****************************************************************" >> $LOG_DIR/$LOG_FILE 
    fi
else
    clear
    echo "*************************************************************"
    echo "*****       	<Your Comments/Company name>                          *******"
    echo "*****                             Load SQL              	                    *******"
    echo "*****         Version 1.00- 14-Jun-2004                                           *******"
    echo "*************************************************************"

    echo "Usage: LoadSQL <data file name> <table name> "
fi

and the .runme file contains


Code:
sqlldr control=$HOME/dump.ctl userid=scott/tiger errors=9999999
But the contents of the dump.ctl will be decided by the tables you have in Oracle.

enc.
Sponsored Links
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 05:55 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