Sponsored Content
Top Forums Shell Programming and Scripting Shell Script to Load data into the database using a .csv file and .ctl file Post 302074581 by encrypted on Wednesday 24th of May 2006 08:09:37 AM
Old 05-24-2006
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.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

unix script to export data from csv file to oracle database

Hello people, Need favour. The problem I have is that, I need to develop a unix shell script that performs recurring exports of data from a csv file to an oracle database. Basically, the csv file contains just the first name and last name will be dumped to an Unix server. The data from these... (3 Replies)
Discussion started by: vinayagan
3 Replies

2. Shell Programming and Scripting

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... (6 Replies)
Discussion started by: chandrashekharj
6 Replies

3. Shell Programming and Scripting

Help shell script to loop through files update ctl file to be sql loaded

I am currently trying to find a way to loop through files in a given directory and for each file modify a ctl file and sql load it. I have been using the sed command to change the infile, badfile parameters of the control file. I have not yet tried to sql load it. Requirement: files are ftp to... (1 Reply)
Discussion started by: dba_nh
1 Replies

4. Shell Programming and Scripting

shell script to read data from text file and to load it into a table in TOAD

Hi....can you guys help me out in this script?? Below is a portion text file and it contains these: GEF001 000093625 MKL002510 000001 000000 000000 000000 000000 000000 000001 GEF001 000093625 MKL003604 000001 000000 000000 000000 000000 000000 000001 GEF001 000093625 MKL005675 000001... (1 Reply)
Discussion started by: pallavishetty
1 Replies

5. Web Development

script to load data from csv file

hello i want a script to load the data line by line from a csv file into a mysql table (3 Replies)
Discussion started by: srpa01red
3 Replies

6. Shell Programming and Scripting

Shell script to find specific file name and load data

I need help as to how to write a script in Unix for the following: We have 3 servers; The mainframe will FTP them to a folder. In that folder we will need the script to look and see if the specific file name is there and load it to the correct table. Can anyone pls help me out with... (2 Replies)
Discussion started by: msrahman
2 Replies

7. Shell Programming and Scripting

why do we need UNIX shell script to load data into Oracle database

Hello everyone, I am new to shell scripting/ loading data into a database. I want to load data into Oracle database using SQL loader. Can some one please explain why do we need unix shell script to load the data into the database? Also can someone please explain what has to be in that script?... (5 Replies)
Discussion started by: new_prog
5 Replies

8. UNIX for Dummies Questions & Answers

Shell script to extract data from csv file

Hi Guys, I am new to shell script.I need your help to write a shell script. I need to write a shell script to extract data from a .csv file where columns are ',' separated. The file has 7 columns having values say column 1,column 2.....column 7 as below along with their values. Name, Address,... (7 Replies)
Discussion started by: Vivekit82
7 Replies

9. Shell Programming and Scripting

Shell script to extract data from csv file

Hi everyone, I have a csv file which has data with different heading and column names as below. Static Data Ingested ,,,,,,,,,,,,Known Explained Rejections Column_1,column_2,Column_3,Column_4,,Column_6,Column_7,,% Column_8,,Column_9 ,Column_10 ,... (14 Replies)
Discussion started by: Vivekit82
14 Replies

10. UNIX for Dummies Questions & Answers

Spooling data from the database in .csv file with boundary

Hi Guys, Another questions to the genius over here. I have spool the dataf from the database into a .csv file. But can it be possible to have all the rows and column with the boundaries..for example the .csv file which i have is as below: 20140327 BU 9A 3 20140327 SPACE 9A 3 20140327... (8 Replies)
Discussion started by: Pramod_009
8 Replies
EDAC-CTL(8)							EDAC admin utility						       EDAC-CTL(8)

NAME
edac-ctl - EDAC admin utility SYNOPSIS
edac-ctl [OPTION]... DESCRIPTION
The edac-ctl program is a perl(1) script which performs some useful administration tasks for EDAC (Error Detection and Correction) drivers. OPTIONS
--help Display a brief usage message. --mainboard Print mainboard vendor and model for this hardware, if available. The method used by edac-ctl to obtain the mainboard vendor and model information for the current system is described below in the MAINBOARD CONFIGURATION section. --status Print the status of EDAC drivers (loaded or unloaded). --register-labels Register motherboard DIMM labels into EDAC driver sysfs files. This option uses the detected mainboard manufacturer and model num- ber in combination with a "labels database" found in any of the files under /etc/edac/labels.d/* or in the labels.db file at /etc/edac/labels.db. An entry for the current hardware must exist in the labels database for this option to do anything. --print-labels Display the configured labels for the current hardware, as well as the current labels registered with EDAC. --labeldb=DB Specify an alternate location for the labels database. MAINBOARD CONFIGURATION
The edac-ctl script uses the following method to determine the current system's mainboard vendor and model information: 1. If the config file /etc/edac/mainboard exists, then it is parsed by edac-ctl. The mainboard config file has the following simple syn- tax: vendor = <mainboard vendor string> model = <mainboard model string> script = <script to gather mainboard information> Where anything after a '#' character on a line is considered a comment. If the keyword script is specified, then that script or exe- cutable is run by edac-ctl to gather the mainboard vendor and model information. The script should write the resulting information on stdout in the same format as the mainboard config file. 2. If no mainboard config file exists, then edac-ctl will attempt to read DMI information from the sysfs files /sys/class/dmi/id/board_vendor /sys/class/dmi/id/board_name 3. If the sysfs files above do not exist, then edac-ctl will fall back to parsing output of the dmidecode(8) utility. Use of this utility will most often require that edac-ctl be run as root. SEE ALSO
edac(3), edac-util(1) edac-utils-0.18-1 2011-11-09 EDAC-CTL(8)
All times are GMT -4. The time now is 01:43 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy