Iandev Smarter Business - Logo Cor
Navegação no fórum
para criar postagens e tópicos.

Filtro para criação de tabela

Caso for preciso criar alguma tabela no banco,
para automatizar o processo foi elaborada a seguinte rotina:
[i]Firebird[/i]:
[code]
# Procura se a tabela [i]xxxx[/i] já existe
sql Select count(*) as TABELA from lower(rdb$relations) where rdb$relation_name = 'xxxx';

# Se não existir, cria
if $c{TABELA} == 0 ;
sql_exec Create table xxxx(campo1 integer, campo2 integer, primary key (campo1));
end_if ;
[/code]

para postgre:
[code]sql select count(*) as tabela from information_schema.tables where lower(table_name) = 'xxxx';[/code]

Para sybase:
[code]sql Select count(*) as TABELA from systable where lower(table_name) = 'xxxx' ;[/code]

Para db2:

[code]
sql select count(*) as TABELA from sysibm.systables where lower(name) = 'xxxx';
[/code]