Re: dbaccess from shell scripts
Posted in 1998
Tony_Reynolds(Accounting & Purchasing System wrote:
>
> Any unix guru's out there?
Hmmm, yes, thanks :-)))
> I'm trying to run an update through a shell script using dbaccess.
> I se up the environment in the script.
> and use dbaccess /home/informix/update.sql
If it is INFORMIXDIR, home of informix, do not place such
things there. If you have dbaccess in your PATH, the script can
be run from anywhere.
> where update.sql is
> say
> update employee
> set employee_name="FRED" where employee_no="1101"
> but what I want to do is make the employee_no a variable so that the
> script asks the user for the employee_no to update.
> Tony Reynolds, NEC Group, Birmingham , UK 8-))
> tr-2959@necgroup.co.uk
> tonyreynolds2@compuserve.com
try something like
------------------
echo What number ?
read enumber
echo What name ?
read ename
echo "update employee \\
set employee_name=\\"$ename\\" \\
where employee_no=\\"$enumber\\"" | dbaccess database name
echo OK
------------------
Michal Hajek
PS: supposing both number is character type (you wrote
number="1101"). In other case, remove \\" sequence from WHERE clause.
PS2: of course, chmode the script to 755 and run it.
PS3: it works in ksh. I suppose no problem in sh, csh, or bash.
--
--------------------------------------------------------------
Michal Hajek mailto:hajek@nspuh.cz
Sprava NIS http://www.nspuh.cz
NsP Uherske Hradiste phone : voice +420 0632 529 204
Purkynova 365 fax +420 0632 551 014
686 68 Uherske Hradiste Czech Republic
--------------------------------------------------------------