Re: checking if sequence exists

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thara Vadakkeveedu <tharagv@xxxxxxxxx> 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


-- 
Sent via pgsql-admin mailing list (pgsql-admin@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin





[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux