Re: dbaccess syntax
Posted in 1997
Aaron Savage wrote:
>
> I am probably being rather stupid here and there is bound to be a
> perfectly straight forward answer.
>
> For reasons I wont bore you with, I am required to access an informix
> database from a remote machine using dbaccess.
>
> Everything is fine with the comms as I can run dbaccess itself from the
> remote machine.
>
> My problem however is that it was my understanding that you could call
> dbaccess with arguments to execute a query and have the results returned
> to you.
>
> we are running dbaccess <name_of_database> - SQL_QUERY
There are two ways that you can do this and you seem to have confused
and merged them try either of the following to run a query from a file:
dbaccess {-e} mydatabase myscript.sql > results.file
-OR-
dbaccess {-e} mydatabase - < myscript.sql > results.file
The main difference is that the former will stop on the first SQL error
while the second format will continue to the next statement. The '-e'
option will echo the query to the results file. If you want to have
the query come from the command line you can use the second format with
a 'here document':
dbaccess mydatabase - <<eoq
select * from mytable where somekey = 'p';eoq
Art S. Kagel