RE: SQL from the command line
Posted in 1995
A better non script way is to use a UNIX here file, i.e.
isql database <<!
select *
from table!
The Bang can be any character, but with this syntax, the bang appearing at
the beginning of a line terminates the input. Look at the man page for the
unix shells for more info on here files.
=====================================================================
Paul Watje Data Administrator
watjep@hasting.com Hastings Books, Music, & Video
----------
From: ilist
To: informix-list
Subject: SQL from the command line
Date: Tuesday, February 21, 1995 9:29PM
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