×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

commandline dbaccess

commandline dbaccess

commandline dbaccess

(OP)
hi, i am pretty new to informix and would appreciate an answer to this doubt..I would like to know how can i batch execute multiple .sql files from commandline using dbaccess and then direct the output to a file. Thanks in advance.

RE: commandline dbaccess

In Unix create a command file containing the following;

dbaccess 'DBNAME' -<<!
'SQL #1';
'SQL #2';
!

If the command file you created is called mysql.sh run it as follows;

nohup mysql.sh &

This will execute SQL #1 followed by SQL #2 (against database DBNAME) and save the output in a file named nohup.out

Make sure the last ! is the first character in the first column.

RE: commandline dbaccess

(OP)
Thanks a lot Richman, I have just one more question, is it possible that i can package some scriptfiles and the .sql files together in the same commandfile and execute it, will the scripts get executed as well?

RE: commandline dbaccess

If I understand you correctly the answer is yes. The piece of code I supplied can be wrapped with unix shell commands. The stuff in between the !'s are for the database only - the remainder is for the shell. e.g.;

echo "`date` Selecting rows from table ABC . . ."

dbaccess 'DBNAME' -<<!
unload to abc.unl
select
*
from ABC
;
!

echo "`date` Selected rows from table ABC . . ."

I wrote the echo commands (in this case) to tell me what the sql is doing. Try it with your shell script(s). Happy Halloween!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close