Panther: EXISTS or NOT EXISTS

This article is written in English and Portuguese
Este artigo est� escrito em Portugu�s e Ingl�s

English version:

I'll continue with the quick and easy posts about Panther (v11.70). This time I'll focus on some new SQL that was added in Panther. Most (if not all) CREATE and DROP statements now allow for IF NOT EXISTS and IF EXISTS clauses respectively. These clauses allow us to write CREATE/DROP statements that will not raise errors in case the objects already exist and we're trying to create them, or when they don't exist and we're trying to drop them.
As an example:


panther@pacman.onlinedomus.net:fnunes-> onstat -

IBM Informix Dynamic Server Version 11.70.UC1 -- On-Line -- Up 00:03:17 -- 369588 Kbytes

panther@pacman.onlinedomus.net:fnunes-> dbaccess stores -

Database selected.

> DROP TABLE test;

206: The specified table (test) is not in the database.

111: ISAM error: no record found.
Error in line 1
Near character position 15
> DROP TABLE IF EXISTS test;
>

These two clauses can be used for TABLE, PROCEDURE, FUNCTION, DATABASE, INDEX, ROLE etc. (both for create and drop).
This can be used in scripts to prevent that they abort prematurely. Also interesting is the fact that this syntax can be found on mySQL. So it's easier now to port existing code into Informix.



Vers�o Portuguesa:

Vou continuar com os artigos r�pidos e f�ceis sobre a vers�o 11.70 (Panther). Desta vez vou abordar uma mudan�a no SQL que foi adicionada ao Panther. A maior parte (se n�o todas) as instru��es CREATE e DROP suportam agora as cl�usulas IF NOT EXISTS e IF EXISTS respectivamente. Estas cl�usulas permitem-nos escrever instru��es CREATE/DROP que n�o geram erros caso os objectos j� existam e os estejamos a tentar criar, ou quando n�o existem e os estamos a tentar eliminar.
Como exemplo:


panther@pacman.onlinedomus.net:fnunes-> onstat -

IBM Informix Dynamic Server Version 11.70.UC1 -- On-Line -- Up 00:03:17 -- 369588 Kbytes

panther@pacman.onlinedomus.net:fnunes-> dbaccess stores -

Database selected.

> DROP TABLE test;

206: The specified table (test) is not in the database.

111: ISAM error: no record found.
Error in line 1
Near character position 15
> DROP TABLE IF EXISTS test;
>

Estas duas cl�usulas podem ser usadas para TABLE, PROCEDURE, FUNCTION, DATABASE, INDEX, ROLE etc. (tanto para o CREATE como para o DROP).
Isto pode ser usado em scripts para evitar que abortem prematuramente. Tamb�m � interessante o facto de que esta sintaxe pode ser encontrada no mySQL. Portanto ser� agora mais f�cil portar c�digo existente para Informix