Re: check table existence...

From: Alban Hertroys <alban(at)magproductions(dot)nl>
To: Shoaib Mir <shoaibmir(at)gmail(dot)com>
Cc: "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: check table existence...
Date: 2007-01-15 16:03:08
Message-ID: 45ABA5BC.3070608@magproductions.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Shoaib Mir wrote:
> Something like this will help you......

Or shorter:

> =======================
>
> CREATE OR REPLACE FUNCTION public.check_table(varchar, varchar)
> RETURNS boolean AS $$
> DECLARE
> v_cnt integer;
> v_tbl boolean;
> BEGIN

PERFORM 1 FROM pg_tables where tablename = $1 and

> schemaname = $2;

RETURN FOUND;

> END;
> $$ LANGUAGE 'plpgsql'

I'm pretty sure that should work.

--
Alban Hertroys
alban(at)magproductions(dot)nl

magproductions b.v.

T: ++31(0)534346874
F: ++31(0)534346876
M:
I: www.magproductions.nl
A: Postbus 416
7500 AK Enschede

// Integrate Your World //

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Alban Hertroys 2007-01-15 16:07:30 Re: Autovacuum Improvements
Previous Message thatsanicehatyouhave 2007-01-15 15:57:42 Glacially slow nested SELECT