Re: Running SQL from unix shell script
Posted in 1997
Patrick Stacey wrote:
> I want to run a shell script which checks for expiry of accounts in the
> table 'accts_esq_free' in my 'subscription' database.
>
> what is the syntax from the solaris command line?
>
> I tried the following but of course it does not work:
>
> -------
> dbaccess subscription <username> <password>;
> unload to 'expired_users.txt' select aid,email from accts_esq_free where> expiry_dte < TODAY;
> -------
>
> what SHOULD be the syntax please?
>
> many many thanks,
>
> Patrick
Check out the DB-Access User Manual. See the section entitled "Executing a
Command File"
in chapter one on page 1-20, and the section entitled "Other Command Line
Features" on page
1-25 (also in chapter one of the manual).
If you don't have the manual, it is available online at INFORMIX's web site
at
http://www.informix.com/answers.
If you still don't want to RTFM, then you basically have two choices:
1. Put the SQL statements in a separate file and give that file's name a
".sql" extension -
e.g. myfile.sql
Then type the command
dbaccess <database name> <file name>
2. Write a UNIX shell script file containing something like the following:
dbaccess <database name> - <<EOT
<your SQL statements>
EOT
HTH,
Avi.
************************************************************************
/\\ \\ /| Avi Abrami, Analyst/Programmer, Telegate Ltd.
/__\\ \\ / | 7 Haplada Street, Or-Yehuda, ISRAEL
/ \\ \\/ | Phone:+972-3-5388717 Fax:+972-3-5335877 eMail:avia@telegate.co.il