Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2010
    Posts
    1

    Unanswered: Retrieve name, run sql and load data.

    Hi all,
    I am new to scripting. I want to automate things.
    I get file named as NY.csv, CA.csv,FL.csv in folder /apps/data. Now these NY,CA and FL have existing data in two tables.
    1. I want to retrieve the name NY first from the filename
    run 2 queries:
    delete * from TABLENAME1 where state='retrieved name from file i.e.(NY)';
    commit;
    delete * from TABLENAME2 where state='NY';
    commit;
    and load the new NY.csv via crontab ( i already have the crontab setup done) . then do the same for CA and then for FL.


    Thanks in advance.

  2. #2
    Join Date
    Sep 2009
    Location
    Ontario
    Posts
    1,057
    Provided Answers: 1
    Code:
    !#/usr/bin/ksh
    cd /apps/data
    list=`ls ??.csv`
    for file in $list
    do
       state=`echo $file|cut -d"." -f1`
       sqldelete1 $state
       sqldelete2 $state
       sqladd3 $file
    done
    You should also consider that there may be PA.csv that should not be processed.
    The entire process should be in your cron job.

Posting Permissions

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