Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2007
    Posts
    7

    Unanswered: 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

  2. #2
    Join Date
    Jun 2004
    Location
    Long Island
    Posts
    696
    You need to look at Oracle SQL*Loader (sqlldr) my friend.

  3. #3
    Join Date
    Jun 2007
    Location
    London
    Posts
    2,527
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •