Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Creating script to read many files and load into database via single control file Post 303042114 by niti_sharma on Sunday 15th of December 2019 09:33:49 AM
Old 12-15-2019
Creating script to read many files and load into database via single control file

Hi,
I have many files but with only 2 names , I want to load the data of that file into database through sqlldr with single control file. how can i do that ?????
Example:
Code:
switch_file
switch_file
billing_file
billing_file

now these files should be loaded into same database but different tables.
Code:
for i in $(ls /tmp*.switch) ; 
do
  sed -i "s|FILENAME|$i|g" /tmp/data1.ctl  --Read
  sqlldr TNS control=/tmp/data1.ctl
  sed -i "s|i|FILENAME|g" /tmp/data1.ctl
done

for i in $(ls /tmp*.billing) ; 
do
  sed -i "s|FILENAME|$i|g" /tmp/data1.ctl  --Read
  sqlldr TNS control=/tmp/data1.ctl
  sed -i "s|i|FILENAME|g" /tmp/data1.ctl
done

COntrol FIle:

Code:
load data 
infile 'FILENAME' "str '\r\n'"
append
into table TEXT
fields terminated by ' '
trailing nullcols


Last edited by Neo; 12-15-2019 at 11:04 AM.. Reason: Code Tags Please See YT Video on this: https://youtu.be/4BuPvWJV__k
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

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? :confused: (3 Replies)
Discussion started by: Csmani
3 Replies

2. 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

3. Shell Programming and Scripting

Need shell script to read two file at same time and print out in single file

Need shell script to read two file at same time and print output in single file Example I have two files 1) file1.txt 2) file2.txt File1.txt contains Aaa Bbb Ccc Ddd Eee Fff File2.txt contains Zzz Yyy Xxx (10 Replies)
Discussion started by: sreedhargouda
10 Replies

4. Shell Programming and Scripting

awk: creating a fixed-width single file from 2 different files

I have to create a single file from three files, Please see below for samples: day.txt 20090101 20090102 item.txt 123456789101 12345678910209 1234567891 str.txt 1 12 123 output.txt 20090101123456789101 1 0 2009010112345678910209 12 ... (2 Replies)
Discussion started by: tamahomekarasu
2 Replies

5. Shell Programming and Scripting

Creating a control file for a group of files

Hi, We have almost 45,000 data files created by a script daily. The file names are of format-ODS.POS.<pharmacyid>.<table name>.<timestamp>.dat. There will be one data file like this for each pharmacy and each table.(Totally around 45,000) The requirement is to create a control file for each... (2 Replies)
Discussion started by: Maya_Pillai
2 Replies

6. 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

7. Shell Programming and Scripting

How to read file and load data into a script as variable

I need to read a text file that contain columns of data, i need to read 1st column as a function to call, and others are the data i need to get into a ksh script. I am quite new to ksh scripting, i am not very sure how to read each row line by line and the data in each columns of that line, set... (3 Replies)
Discussion started by: gavin_L
3 Replies

8. UNIX for Advanced & Expert Users

Load a file from UNIX into database

Hi, I want your help to see if there is a way wherein we can load a set of files which are lying in unix server into my database using sql loader. Also the person who will be running sql loader does not have access to unix system. So is there a way i can provide any sql loader script wherein... (1 Reply)
Discussion started by: Vivekit82
1 Replies

9. UNIX for Beginners Questions & Answers

Generic script to load file details(ls -ltr) in to a database.

All, I am trying to create a report on the duration of an ETL load from the file arrival to the final dump in to a database for SLA's. Does anyone have any guidance or ideas on how metadata can be extracted; information of a file: like file name, created timestamp, count of records and load... (1 Reply)
Discussion started by: pradeepp
1 Replies

10. UNIX for Beginners Questions & Answers

Script for creating Control file in UNIX

Delete ---- Original post, restored by mod after being deleted by abhilashnair ---- I have a requirement where, I need to create a control file which will have 3 columns in the header row as below: Filename Count Checksum This above control file has to contain metadata as above... (2 Replies)
Discussion started by: abhilashnair
2 Replies
kdb_util(8krb)															    kdb_util(8krb)

Name
       kdb_util - Kerberos database utility

Syntax
       /var/dss/kerberos/bin/kdb_util operation filename [ database ]

Arguments
       operation
		Function to perform on the database. The operation argument must be one of the following values:

		load   Converts the database in file filename, to format and overwrites the database specified.

		dump   Converts the database into form, and writes the result to file, filename.

		slave_dump
		       Performs  the same function as dump, and creates the file when finished.  The is used by to determine if a slave_dump is in
		       progress, or if it did not complete successfully.

		new_master_key
		       Prompts you for the old key of the Kerberos database as well as a new master key.  It converts  the  database  into  format
		       and,  at the same time, decrypts those sections of the database encrypted with the old master key and re-encrypts them with
		       the new master key.  The result is written to the file, filename.

       filename The name of the source file for the load operation or the destination file for the  operations:  dump,	slave_dump,  and  new_mas-
		ter_key.

       database The name of the database.  If the argument is not included, the Kerberos database is stored in files and by default.

Description
       The  command  allows  the Kerberos administrator to perform several functions on the entire Kerberos database of a master or slave Kerberos
       server in one operation.  The database argument specifies the name of the Kerberos database.  The Kerberos database utility reads from  and
       writes to the Kerberos database and, in addition, it reads from and writes to a file in format:	 filename.  A file is an ASCII representa-
       tion of a Kerberos database.  The functions that can be specified by the operation argument are listed in the Arguments section.

       Whenever the Kerberos database is changed by the modification time of is updated.  The file indicates the age of the database.

Files
       See Also
	      krb_dbase(5krb), kdb_init(8krb), kdb_edit(8krb), kdb_destroy(8krb), kstash(8krb)

																    kdb_util(8krb)
All times are GMT -4. The time now is 11:41 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy