Call SQL LOADER FROM UNIX


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Call SQL LOADER FROM UNIX
# 1  
Old 09-16-2015
Call SQL LOADER FROM UNIX

HI Experts,

I am pretty new to scripting and i need to create a perl or shell script which should fetch a file from local directory and insert the data into a table using sql loader. This will be later added to chron job to run daily and fetch all files and load them into
the table.

Also i need the insert the file name as a value in a column while loading data. If any of you actually worked on this kind of task please help me.


This is what i need to do



file: FILE_NAME.txt



Code:
CODE DATE
1234 01012015
1345 01012015
3456 01012015


after loading the date the table should look like this

Code:
CODE DATE FILE_NAME
1234 01012015 file_name.txt
1345 01012015 file_name.txt
3456 01012015 file_name.txt

we need to store this file name because there will be multiple files being placed in that location and
each file has different functionality. Please help me.

Last edited by Corona688; 09-16-2015 at 06:13 PM..
# 2  
Old 09-17-2015
Please, try any of these:

Code:
$ awk '{printf "%-8s%-12s%s\n", $1, $2, FNR==1 ? "FILE_NAME" : FILENAME}' sam1234.file 
CODE    DATE        FILE_NAME
1234    01012015    sam1234.file
1345    01012015    sam1234.file
3456    01012015    sam1234.file

Code:
$ awk 'FNR==1{print $0, "FILE_NAME"; next}{print $0, FILENAME}' OFS='\t' sam1234.file
CODE         DATE       FILE_NAME
1234        01012015    sam1234.file
1345        01012015    sam1234.file
3456        01012015    sam1234.file

Code:
$ awk 'FNR==1{print $1, $2, "FILE_NAME"; next}{print $1, $2, FILENAME}' sam1234.file
CODE DATE FILE_NAME
1234 01012015 sam1234.file
1345 01012015 sam1234.file
3456 01012015 sam1234.file

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to call SQL Loader in shell script?

HI Experts, I am pretty new to scripting and i need to create a perl or shell script which should fetch a file from local directory and insert the data into a table using sql loader. This will be later added to chron job to run daily and fetch all files and load them into the table. Also i... (1 Reply)
Discussion started by: sam1234
1 Replies

2. UNIX for Dummies Questions & Answers

Call SQL LOADER FROM UNIX

HI Experts, I am pretty new to scripting and i need to create a perl or shell script which should fetch a file from local directory and insert the data into a table using sql loader. This will be later added to chron job to run daily and fetch all files and load them into the table. Also i... (1 Reply)
Discussion started by: sam1234
1 Replies

3. Shell Programming and Scripting

Call a pl sql function from unix

hi, I want to know how to call a pl sql function testfunction(param1,..) that returns a value and grab that value in a shell variable. Thnx in advance ---------- Post updated 03-30-10 at 11:58 AM ---------- Previous update was 03-29-10 at 03:49 PM ---------- thnx a lot jim (0 Replies)
Discussion started by: austinhell3_16
0 Replies

4. Shell Programming and Scripting

sql loader for inserting the data from multiple fields from unix

Hi , I have my log file something like this (07/29/2009 00:02:24.467) 367518 (07/29/2009 00:02:26.214) 949384011 (07/29/2009 00:02:26.236) 367524 (07/29/2009 00:02:28.207) 949395117 (07/29/2009 00:02:28.240) 337710 (07/29/2009 00:02:30.621) 949400864 I am trying to insert the data... (3 Replies)
Discussion started by: rdhanek
3 Replies

5. Shell Programming and Scripting

how to handle sql loader errors in unix

hi all, how to handle sql loader errors in unix shell ?? thanks in advance gemini (3 Replies)
Discussion started by: gemini106
3 Replies

6. Shell Programming and Scripting

Can SQL Server call be made from unix sh

Hi, I need to make SQL Server procedure call (exec <proc name>)from unix shell script. First of all I would like to know if it is possible. I know we can do it from Oracle but not sure about SQL Server. Version: SunOS 5.8 SQL 8.0 I have made the below entry in the interface file. NSXNA267 ... (0 Replies)
Discussion started by: sspreethi
0 Replies

7. UNIX for Advanced & Expert Users

Bus error(coredump) while running SQL*Loader in HP Unix 11

Hi All, I am getting coredump error, when I try to execute Oracle SQL*Loader from Shell script in Unix environment. But SQL*Loader from local machine runs fine with same database. SQL*Loader: Release 9.2.0.6.0 - Production on Mon Apr 23 05:23:47 2007 Copyright (c) 1982, 2002, Oracle... (3 Replies)
Discussion started by: srinivas_paluku
3 Replies

8. UNIX for Advanced & Expert Users

How to call SQL procedure from UNIX Shellscript ?

Hi All I would be thankful to you all if you will guide me the steps to call a stored proc. from unix shell script. that stored proc. could be parameterised or parameterless developed in SQL. Any info. in this topic would help me..... Thanks in advance.... (1 Reply)
Discussion started by: varungupta
1 Replies

9. Shell Programming and Scripting

how can I call a pl/sql funciton in unix script

who can show me how to call pl/sql function or precudure in unix script.. cheers, (6 Replies)
Discussion started by: YoYo
6 Replies

10. Shell Programming and Scripting

How to call pl/sql in unix script

sample code as following: test_sql(){ #test#echo test_sql str=`$ORACLE_BIN/sqlplus -s $user/$passwd <<EOM set verify off set heading off set feedback off #--------start pl/sql { DECLARE CURSOR pah_cs IS select id from table where letter = 'abcd';... (6 Replies)
Discussion started by: YoYo
6 Replies
Login or Register to Ask a Question