Re: Error-handling, Variable instead of Identifiers
Posted in 1995
Since mail sent to the return address baier_d@alf1.ngate.uni-regensburg.de bounces,
I'm posting instead...
>From: baier_d@alf1.ngate.uni-regensburg.de
>Date: Thu, 25 May 1995 22:42:37 GMT
>X-Informix-List-Id: <news.14232>
>
>I have propably 2 easy questions, but I am not able to manage these problems
>on my UNIX(r) System V Release 4.0 (MX300I) SIEMENS, Release 5.41
>Version A0010 and INFORMIX-4GL, Version 4.10.U.
>
>1. If I use an error-handling to recognize an already existing table
> 'table_1' before I create it, the programm jumps in my error-function
> and then to a function, that drops this table_1.
> after this my programm should create the new table_1, but INFORMIX
> now overrides the command, which caused the error.
>
> How can I ensure that INFORMIX repeats this command? The same happens with
> CREATE INDEX ...
Don't use WHENEVER ERROR CALL...
MAIN
WHENEVER ERROR STOP
IF create_table() = -310 THEN
CALL drop_table()
IF create_table() != 0 THEN
ERROR "Cannot create table, even after dropping it!"
EXIT PROGRAM 1
END IF
END IF
...
END MAIN
FUNCTION create_table()
DEFINE retval INTEGER
WHENEVER ERROR CONTINUE
CREATE TABLE table_1 (...); WHENEVER ERROR STOP
LET retval = STATUS
RETURN retval
END FUNCTION
FUNCTION delete_table()
DROP TABLE table_1;
END FUNCTION
>2. In this example I can't use a variable, instead of an Identifier 'table_1'.
> So if I have to drop some more tables or indexes I have to write a huge amount
> of CASE ...-commands. Is there a solution?
Use PREPARE & EXECUTE. The limitation is in IBM's (the original version
of) DB2 Embedded SQL (for PL/1), and everybody else inherits lots of
deficiencies from there. There are some justifications for it -- switching
the table name has quite big implications down in the database.
Yours,
Jonathan Leffler (johnl@informix.com) #include <disclaimer.h>