Re: checking for existence of a table in plpgsql.

From: Bo Lorentsen <bl(at)netgroup(dot)dk>
To: Bhuvan A <bhuvansql(at)yahoo(dot)com>
Cc: pgsql-sql <pgsql-sql(at)postgresql(dot)org>
Subject: Re: checking for existence of a table in plpgsql.
Date: 2002-03-14 08:06:39
Message-ID: 1016093199.669.20.camel@netgroup
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Jan Wieck 2002-03-14 15:21:30 Re: Large data sets and FOR LOOP's
Previous Message Bo Lorentsen 2002-03-14 07:57:52 Re: Large data sets and FOR LOOP's