Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2004
    Posts
    143

    Unanswered: running all sql files from a unix directory

    I am on solaris 5.8 and work on a 10.2.0.3 oracle database.
    In my shell scripts, I have

    #!/bin/ksh
    sqlplus -s /NOLOG <<!EOF
    connect user/pwd@database
    @/data/dev/file1.sql
    exit
    !EOF
    exit 0

    The above code is good for executing a single file. Suppose, I want to run all the .sql files in the /data/dev directory, can I get an idea as to what needs to change in the above code ? There may be 100 of them...hence something like

    @/data/dev/file1.sql
    @/data/dev/file2.sql
    .
    .
    .
    @/data/dev/file100.sql

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    One of the approximately 150 ways of doing it would be to
    1) change your script to take the SQL file name as a parameter and
    2) use the find command to run the new script: find . -name "*.sql" -exec yourscript.sh '{}' \;

    Keep in mind that the order of their execution will be random, generally speaking .
    ---
    "It does not work" is not a valid problem statement.

  3. #3
    Join Date
    Feb 2004
    Posts
    143
    Thank you...I am getting real close (but not there yet)

    I have all these file names in a file now...
    ls *.sql >> sqllist

    My sqllist now looks like :
    file1.sql
    file2.sql
    .
    .
    .
    file100.sql

    How can I append a character @ in the first column on all lines in this file... If I get that, then I can run the
    @sqllist
    in my shell script.
    I am looking for something besides the vi editor to get this automated.

  4. #4
    Join Date
    May 2007
    Location
    Milano, Italy
    Posts
    22
    Code:
    printf "@%s\n" *.sql>all_together.sql

Posting Permissions

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