Re: how can I stop drop table error text
Posted in 1994
Shaun writes:
:
: I have the following sql, that I pipe into isql:
:
: drop table xx;
:
: create table xx(
:
: field defns here
:
: );
:
:
: A question - if the table xx is not already defined, how can I stop
: the drop command from giving me an error return? isql bombs out when it
: hits it. Are there any "if" type structures I can put around it to make it
: stop putting out the error text?
:
If you are using 4GL, I suggest you try:
DEFINE oldtab CHAR(18)
SELECT tabname
INTO oldtab
FROM systables
WHERE tabname = xx;
IF SQLCA.SQLCODE = 0 THEN
DROP TABLE xx
END IF
CREATE table xx(...
Or, if you are just using ISQL from a bourne-line shell:
(
isql -s yourdbname <<EOF
SELECT tabname FROM systables WHERE tabname = "xx";EOF
) | grep xx > /dev/null 2>&1 &&
isql -s yourdbname <<EOF
drop table xxEOF
The isql statement following "&&" is only executed if the grep command
returns a zero exit status, which only happens if the table you want to
drop is found in systables.
--
Colin McGrath Internet: colin@scdipc0.ueci.com
Raytheon Engineers & Constructors Inc. UUCP: ..!uunet!trac2000!trac3000!cmm
30 S. 17th St Voice: 215-422-3449
Philadelphia, PA, 19101 FAX: 215-422-3363