Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

informix sql script as batch ?

1,974 views
Skip to first unread message

Helmut Blass

unread,
Aug 8, 2001, 1:36:00 PM8/8/01
to
hi,
my collegue who handles an informix database uses the sql editor to start
sql scripts.
he asked me if it is possible to trigger those scripts at night, in a batch
run.
As I have nothing to do with informix, I hope to get an answer in thiis
usegroup.

thanx for your help, Helmut


Gerard Lapidario

unread,
Aug 8, 2001, 1:56:26 PM8/8/01
to
Save the sql he needs in a file and make sure the file extension is sql
(e.g., myfile.sql).
From the prompt you can run this file via
isql -sq <DATABASE> <FILENAME without the extension>

You could also do something like
echo "select count(*) from myTab" | isql -sq <DATABASE>
if you don't want to go to ISQL or DBACCESS to run and sql command.

So if you wish to run this nightly, create a script, set all the needed
environment variable needed by Informix to run, then execute the sql file.
Place this script file in your cron (I'm assuming that you are in Unix).

"Helmut Blass" <helmu...@t-online.de> wrote in message
news:9krt4i$t5c$07$1...@news.t-online.com...

Richard Kofler

unread,
Aug 15, 2001, 3:15:51 PM8/15/01
to

Hi
sorry for the late answer
If this is NT - I cannot help, someone else please ?
If it is UNIX or dervate - yes, here goes:

Check where your environment variables are set
Can be /etc/profile, can be an init script
Look where INFORMIXSERVER and friends are getting their values

In a shell you can run dbaccess like this:
(I assume sh or ksh as shell)

. environment_for_informix.sh # this line starts with <dot><blank>
# this script sets up all the environment
# variables INFORMIX will need
dbaccess <databasename> <<EoF >output_goes_here
2>errors_and_techie_output_goes_here
set isolation to ..... ;
.........
set lock mode to ..... ;
........
select ...
.... ${Variables} will be replaced by the shell
...
;
EoF

Now it is IMPORTANT, that 'EoF' or whatever string you put after '<<'
into
the first line is exactly the same string here AND starts in column 1
no indentation here! (This is called inplace shell input - a standard
shell feature)

If you put these lines into a file and make it executable you can test
it
from your terminal. I do assume here that this test only select
things, or
in other words, can be repeated

Now if it does what you want you place it into cron.
man cron will tell you all the details.

And you must consider that cron only knows about environment
variables, if
you explicitely set them. This is what the line starting with <dot>
does by
sourcing a script file
Typical line in there are:
INFORMIXSERVER=myserver
export INFORMIXSERVER

and so on

HTH
Dic_k

Another shameless plug from mla:
Magic is REAL unless declared INTEGER

--
Richard Kofler
T-Systems
debis Systemhaus Austria / Vienna
on a private e-mail account

Leonid Vorontsov

unread,
Aug 17, 2001, 7:37:59 AM8/17/01
to
"Helmut Blass" <helmu...@t-online.de> wrote:
> he asked me if it is possible to trigger those scripts at night, in a
batch
Start SQL Editor, choose:
Help -> Help Topics -> Reference -> Command Line Options
and read how to start script in batch. To start batch automatically
use "Task Scheduler" service.

Jim dJ

unread,
Aug 17, 2001, 11:06:30 AM8/17/01
to
On Unix you could also put something like the following into a shell script and
then set the shell script to run through cron:

$INFORMIXDIR/bin/dbaccess databaseName <<EOF
select amount from inventory where itemDescription = "baseball"
EOF

Jim

On Fri, 17 Aug 2001 14:37:59 +0300, in article
<9livnh$9b3f1$1...@ID-79143.news.dfncis.de>, Leonid Vorontsov stated...

Brad Patterson

unread,
Aug 20, 2001, 12:46:21 PM8/20/01
to
Since you mentioned SQL Editor, you seem to be running on NT/2000. NT
has an "at" command that can schedule jobs to run at certain times.
You can look in Windows Help to see the syntax. (index, type "at")

What job you choose to run at a certain time is up to you. SQL Editor
has a bunch of parameter flags to run it in a pseudo dbaccess mode.
If your environment is set correctly, you should be able to call
dbaccess.exe. Also, look in %INFORMIXDIR%\bin for .cmd and .bat files
which create the demo databases for ideas how to create SQL scripts.

Brad Patterson

Jim dJ <nos...@newsranger.com> wrote in message news:<Wpaf7.4797$2u.4...@www.newsranger.com>...

0 new messages