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