Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search for
  Advanced Search

Re: IF EXISTS


  • From: "P.M" <pmdanger(at)yahoo(dot)com>
  • To: davidtecher(at)yahoo(dot)fr, PostgreSQL FR <pgsql-fr-generale(at)postgresql(dot)org>
  • Subject: Re: IF EXISTS
  • Date: Sun, 20 Nov 2005 05:16:11 -0800 (PST)
  • Message-id: <20051120131615(dot)37006(dot)qmail(at)web33202(dot)mail(dot)mud(dot)yahoo(dot)com>

Merci pour ton aide...mais en fait cela ne m'ai pas utile car je developpe une application en VB.net 2005.

Cette application doit etre capable de creer une database sous different RDBMS comme oracle, MSSQL, MySQl ou meme PostgreSQL.

donc je souhaite avec une commande SQL qui me permette de faire ce DROP IF EXISTS.

Comme cela fonctionne sous les autres RDBMS, j'esperais que cela puisse exister sous PostgreSQL.

Merci,
maileen


david techer <davidtecher(at)yahoo(dot)fr> wrote:
Bonjour

Personnellement je n'ai encore eu le temps de tester la 8.1.0 pour savoir celà!

 Ayant que la 8.0.4 d'installée sur ma bécane,  j'utilise la fonction suivante si celà peux-vous intéresse r pour tester si une table existe et l'effacer le cas éventuel:

select drop_table_if_exists('matable', false);

dont la synthaxe est:

CREATE OR REPLACE FUNCTION drop_table_if_exists(text, bool) RETURNS text AS '
DECLARE
opt text;
rec record;
BEGIN
IF $2 THEN
opt := '' CASCADE'';
ELSE
opt := '''';
END IF;

IF NULLVALUE($1) THEN

RETURN ''ATTENTION: Table non trouvée'';

ELSE

SELECT INTO rec tablename FROM pg_tables WHERE tablename like $1;

IF FOUND THEN
EXECUTE ''DROP TABLE '' || $1 || opt;
RETURN ''Effacement de la table ''|| $1 || ''...OK'';
END IF;

END IF;

RETURN ''ATTENTION: Table ''|| $1 || '' non trouvée'';

END;
' LANGUAGE 'plpgsql';

--david;
-------------------------------------------------
Jean David TECHER
e-mail: davidtecher(at)yahoo(dot)fr
site: http://techer.pascal.free.fr/postgis/ -------------------------------------------------


P.M a écrit :
 Bonjour a tous,

J'aimerai savoir si la commande IF EXISTS, existe sous PostgreSQL 8.1 car je n'ai rien trouve de tel jusqu'a present lorsque je desire faire un DROP.

Quelqu'un pourrait-il m'aider SVP ?
merci,

Maileen

Yahoo! FareChase - Search multiple travel sites in one click.


Yahoo! FareChase - Search multiple travel sites in one click.

Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2008 PostgreSQL Global Development Group