Results 1 to 3 of 3
  1. #1
    Join Date
    May 2016
    Posts
    3

    Unanswered: Need help to write a function in shell scripting to execute sql files

    Hi,

    I am new to shell scripting and i need to write a automation script to execute sql files. I need to check the table if it is there in system tables and need to write a function to call the .sql files.

    For ex. I have a.sql,b.sql,c.sql files, where the sql file contains DELETE and INSERT queries.

    I am using Netezza as database.

    Thanks in advance.

    Cheers,
    Samah

  2. #2
    Join Date
    May 2005
    Location
    South Africa
    Posts
    1,365
    Provided Answers: 1
    What command do you use to execute the scripts from the command line? Just replace the ls command in below with your netezza command (the sql to check the system tables should be in your .sql files?).
    Code:
    for f in a.sql b.sql c.sql
    do
      ls -l $f >$f.log 2>&1
    done

  3. #3
    Join Date
    May 2016
    Posts
    3

    Need help to write a function in shell scripting to execute sql files

    Hi pdreyer,

    Thanks for your reply.

    I need to write a function and put it in one shell script.For example my script name is Test.sh then i will be using "nohup Test.sh > test.log>&1 &" to run.

    In this Test.sh, I need to write a function to call the .sql files, by using function name i need to call the sql files but i am getting error when i tried with my code . I have 18 files(.sql files) to execute.For example

    Runsql a.sql
    Runsql b.sql
    RUn c.sql by passing parameters, here in the above example Runsql is a function name which needs to call the .sql files.

    Hope you understand my requirement!

    Thanks,
    Samah

Posting Permissions

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