Re: if EXISTS in ksh script
Posted in 1998
Topics: Server Administration
There will doubtless be many answers about how this could be done more
elegantly in Perl or something else, but the simplest way would be
#!/bin/ksh
dbaccess dbname <<EOF > /dev/null 2>&1
create table foo(bar char(1)); EOF
This assumes, of course, that you have need to create a table called foo
with a char(1) attribute called bar, but I think you can improvise from
here. The idea is that you will create the table if it doesn't exist, and
any messages (including failure) will go to /dev/null. The only problem is
what happens if there is a database problem with the script runs, but you
can solve that
fairly easily.
David
"Don Boling" <dboling@vnet.net> on 10/28/98 07:59:04 PM
Please respond to "Don Boling" <dboling@vnet.net>
To: informix-list@iiug.org
cc: (bcc: David Coburn/ISG/WVUS/WorldVision)
Subject: if EXISTS in ksh script
I am trying to test if a table exists in a korn shell script
before I execute "create table (...) "
I have not found any reference in Informix SQL manuals on how to do this...
any suggestions would be greatly appreciated....
Don
dboling@vnet.net