Received: from secure.webhotel.net (secure.webhotel.net [195.41.202.80]) by postgresql.org (Postfix) with SMTP id 068E247589B for ; Thu, 14 Mar 2002 03:06:40 -0500 (EST) Received: (qmail 69174256 invoked from network); 14 Mar 2002 08:11:16 -0000 Received: from unknown (HELO localhost.localdomain) (217.157.135.140) by mail.webhotel.net with SMTP; 14 Mar 2002 08:11:16 -0000 Subject: Re: checking for existence of a table in plpgsql. From: Bo Lorentsen To: Bhuvan A Cc: pgsql-sql In-Reply-To: References: Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Evolution/1.0.2 Date: 14 Mar 2002 09:06:39 +0100 Message-Id: <1016093199.669.20.camel@netgroup> Mime-Version: 1.0 X-Archive-Number: 200203/180 X-Sequence-Number: 7060 On Thu, 2002-03-14 at 06:40, Bhuvan A wrote: > how can one know that a particular table exists or not in plpgsql? How about : SELECT INTO cnt count( * ) FROM pg_class WHERE relname='mytable'; IF FOUND THEN ... END IF; or IF cnt > 0 THEN ... END IF; This plpgsql snip, will find the number of classes that have the "mytable" name. Would this do the trick ? /BL