Re: checking if sequence exists - Mailing list pgsql-admin

From Kevin Grittner
Subject Re: checking if sequence exists
Date
Msg-id 1384569839.58633.YahooMailNeo@web162903.mail.bf1.yahoo.com
Whole thread Raw
In response to Re: checking if sequence exists  (Thara Vadakkeveedu <tharagv@yahoo.com>)
List pgsql-admin
Thara Vadakkeveedu <tharagv@yahoo.com> wrote:

> By itself this sql works:

> SELECT 0 FROM pg_class
>              WHERE relkind = 'S'
>                AND oid = ('public.' || quote_ident('hibernate_sequence'))::regclass;
>
> However when I create a function for it and run it I see an error
>
> create function chk_sequence() returns integer as $$
> BEGIN
> IF EXISTS (SELECT 1 FROM pg_class
>              WHERE relkind = 'S'
>              AND oid = ('public.' || quote_ident('hibernate_sequence')))::regclass
>   THEN
>         return 1;
>   ELSE
>  return 0;
>     END IF;
> END;
> $$ language plpgsql;

Move the cast to regclass inside one level of parentheses.

--
Kevin Grittner
EDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


pgsql-admin by date:

Previous
From: Bob Lunney
Date:
Subject: Re: checking if sequence exists
Next
From: Albe Laurenz
Date:
Subject: Re: MultiXactId Error in Autovacuum