[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

dbaccess script

Posted on 2011-04-27
3
Medium Priority
?
330 Views
Last Modified: 2012-05-11
I am looking to automate a query in our database using dbaccess.  I have the start of the file and the query but am not sure how to automate this.  My files starts with:

dbaccess -qn  (this brings me to start my select statement but I've been looking around the internet and don't see how to add the select statement in so it automatically runs.  Manually everything works fine).  Also, I would like to save this query to a file on the server.

Any help would be appreciated.
0
Comment
Question by:cbones
  • 2
3 Comments
 
LVL 16

Expert Comment

by:Bryan Butler
ID: 35475916
Can you put your commands in a file or to run from the command line, try:
dbaccess dbname << select here

Here's some links that might help.

http://www.dbforums.com/informix/1200536-query-informix-table-command-line.html
http://www.dbforums.com/informix/1650938-dbaccess-command-line-help-newbie.html
0
 
LVL 16

Accepted Solution

by:
Bryan Butler earned 1000 total points
ID: 35475945
0
 
LVL 7

Assisted Solution

by:jhp333
jhp333 earned 1000 total points
ID: 35759078
Make a script file, say "runsql", with the line below.
Give it an execution permission. (type "chmod u+x runsql" at a shell prompt)
Save your sql statements in a file, say "my_queries.sql"
Now type "runsql your_db_name my_queries.sql" at a prompt.
The result will be displayed and also saved in "my_queries.sql.out"

dbaccess -e $1 $2 | tee $2.out 2>&1

Open in new window

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
Sometimes MS breaks things just for fun... In Access 2003, only the maximum allowable SQL string length could cause problems as you built a recordset. Now, when using string data in a WHERE clause, the 'identifier' maximum is 128 characters. So, …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question