Re: Command Line execution of sql statement
Posted in 2003
In article <bbogt7$qps$1@terabinaries.xmission.com>,
gsturkenboom@lic.co.nz writes
>
>
>The usual method is to run something like
>
>dbaccess <dbname> <script>
>
>where <dbname> is the name of your database
>and <script> is the name of a script file with a filename extension of .sql
>
>Not sure about isql but this probably works in a similar fashion
One can also do something along the lines of:
myscript.sh:
INFORMIXDIR=/dir; export INFORMIXDIR
PATH=$PATH:$INFORMIXDIR/bin; export PATH
DBPATH=/dbpath # SEexport DBPATH
dbaccess mydb - << EOT
select * from mytable;
select * from anothertable;etc.
EOT
with some redirection after the EOT
Of course if you are doing lots of these you want the stuff to set the
environment in a separate script so it's in one place only:
myscript.sh:
. /scripts/livebd
dbaccess etc.
>
>Hi all,
> I am not sure how to do this, but what I want to do is have a cron
>job execute a sql statement and dump the results in to a comma
>delimited file. I know how to do everything but actually execute the
>query. I have led to believe that this can be done with isql or
>dbaccess. Any help would be appreciated.
--
Five Cats