Translating with DrWatson… this can take a few seconds the first time.
This is a genuine, complex translation. DrWatson protects commands, error codes, and log output while naturally translating the surrounding text. It’s translated once and saved.
Aurelio asked how to execute SQL files from a server console. Art S. Kagel answered with dbaccess databasename myscript.sql, or dbaccess databasename - with the file redirected as input. Vince Pachiano used the same form, noting a .sql suffix is assumed. Richard Kofler suggested a shell here-document with dbaccess -e, so shell variables can be substituted and statements and errors logged. Solved.
Auto-generated by Claude from the posts below — may be imperfect; read the full thread.
Aurelio — — source: Informix-list mailing list archive (1991-1998)
1. How can I execute SQL files from a server console?
Thanks
↪ replying to Aurelio
Art S. Kagel — — source: Informix-list mailing list archive (1991-1998)
Aurelio wrote:
>
> 1. How can I execute SQL files from a server console?
>
> Thanks
dbaccess databasename myscript.sql
OR
dbaccess databasename - <myscript.sql
Art S. Kagel
↪ replying to Aurelio
Pachiano, Vince — — source: Informix-list mailing list archive (1991-1998)
Your Mileage may vary, but I always use
dbaccess <dbname> <sql_file_name>
Note: sql_file_name assumes a ".sql" suffix
-----Original Message-----
From: Aurelio [SMTP:i52sacaa@uco.es]
Posted At: Monday, April 26, 1999 7:38 AM
Posted To: informix
Conversation: Executing SQL from prompt
Subject: Executing SQL from prompt
1. How can I execute SQL files from a server console?
Thanks
In article <37247BA1.6980@bloomberg.net>,
kagel@bloomberg.net wrote:
> Aurelio wrote:
> >
> > 1. How can I execute SQL files from a server console?
> >
> > Thanks
>
> dbaccess databasename myscript.sql
>
> OR
>
> dbaccess databasename - <myscript.sql
>
> Art S. Kagel
>
This is my 0.02 Euro
If I have some variables from the shell environment to throw in
I always use
dbaccess -e databasename <<EOF >the_statements_and_the_results.log \\
2>the_errors.log-- SQL-text using shell variables like $TABLE for instance:
select
*
from
$THIS_TABLE
where
$THIS_COLUMN = "$COMPARE_STRING"
;
all the $variables have to be preset in the shell, of course
I often use parameters to the script
The '-e' flag for dbaccess makes the sql-text visible in the log file
It is useful, when you have errors.
You may want to omit that after debugging is done
--
Richard Kofler
debis Systemhaus EDVg
a Daimler Chrysler Enterprise
Vienna / Austria
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
Your privacy choices
We use strictly necessary cookies to make this site work. With your
consent we’d also use optional cookies for analytics and marketing. You can accept all,
reject all, or choose. Read our Cookie Policy.