If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > load filenames to oracle table

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-23-07, 18:56
maan_myra maan_myra is offline
Registered User
 
Join Date: Sep 2007
Posts: 7
load filenames to oracle table

I have csv filenames on my UNIX directory that I download from FTP site and here's what i want to do next....

copy all csv filenames (only) and insert to and oracle table with date at the end.

ex.
UNIX Filenames
file1.csv
file2.csv


ORACLE filenames after upload.
file1_071023.csv
file2_071023.csv
Reply With Quote
  #2 (permalink)  
Old 12-19-07, 11:57
PMASchmed PMASchmed is offline
Registered User
 
Join Date: Jun 2004
Location: Long Island
Posts: 696
You need to look at Oracle SQL*Loader (sqlldr) my friend.
Reply With Quote
  #3 (permalink)  
Old 12-20-07, 06:40
mike_bike_kite mike_bike_kite is offline
vaguely human
 
Join Date: Jun 2007
Location: London
Posts: 2,519
Code:
#!/bin/ksh

cd /your/directory/goes/here

TODAY=`date '+%y%m%d'`

for OLD_NAME in `ls -1 *.sh`
do
        NEW_NAME=`echo $OLD_NAME | sed "s/\./_$TODAY./"`

        CONNECT_TO_DB <<- END_SQL
                insert  MyTable
                values  ( "$NEW_NAME" )
                go
        END_SQL
done

exit 0
If you just want a shell script to store the filenames, with a date, in a table then the above should work fine. You'll need to :
  • set the correct directory
  • check the syntax for the insert (I haven't done Oracle for a long time)
  • put in the correct command and params to access your database from shell.

Mike
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On