Re: SQL from the command line
Posted in 1995
Topics: Server Administration
Hi,
Try these :
1. Batch mode
----------
echo "sql command" | dbaccess <DBname>
echo "select * from systables where tabid < 20" | dbaccess mydb
2. Interactive mode
----------------
dbaccess <DBname> -
dbacess mydb -
>select * from systables where tabid < 20 ; .
.
output
.
.
>New command ended with semi column OR ctrl-D to finish interactive sql
/\\__/\\
____________________________________________________________/..\\_________
Shpigelman Moshe (Chin) /_--_\\
Product Mgmt. & Development Manager \\/
Com Software Ind. e-mail : chin@applicom.co.il
16, Hagalim blvr. Herzelia 46725 Tel : 972-9-598988
Herzelia 46725 Tel, Dir : 972-9-598974
ISRAEL Fax : 972-9-598980
_________________________________________________________________________
On 21 Feb 1995, Andy Cordell wrote:
> Date: 21 FEB 1995 21:29:54 GMT
> From: Andy Cordell <andy@bnr.ca>
> Newgroups: comp.databases.informix
> Subject: SQL from the command line
>
> Hello all,
>
> What is the proper way to provide a SQL command line interface to
> a user without making them create a sql command file to issue a
> command? What I'd like is the ability to type something like
> this on the unix command line:
>
> <dbname> <SQL command here>
> The response would come back to stdout.
>
> This is the almost working script that I wrote:
>
> #! /bin/sh
> echo "$@" > temp.sql
> dbaccess -e <dbname> temp.sql>
> The only problem with this is that it expands the * in
> "select * from <table> " to be the current directory listing, so
> I end up with :
> select <insert really big directory listing here> from <table>
> as my SQL command, which is not good.
>
> Is this the right approach? Is there already a utility that will
> provide SQL statements (not cmd files) from the command line?
>
> Any help is much appreciated!
>
> Andy Cordell
> andy@bnr.ca
>
>
>