| From: | Kevin Grittner <kgrittn(at)ymail(dot)com> |
|---|---|
| To: | Thara Vadakkeveedu <tharagv(at)yahoo(dot)com>, "pgsql-admin(at)postgresql(dot)org" <pgsql-admin(at)postgresql(dot)org> |
| Subject: | Re: checking if sequence exists |
| Date: | 2013-11-16 02:43:59 |
| Message-ID: | 1384569839.58633.YahooMailNeo@web162903.mail.bf1.yahoo.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-admin |
Thara Vadakkeveedu <tharagv(at)yahoo(dot)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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Strahinja Kustudić | 2013-11-16 20:25:26 | Re: |
| Previous Message | Bob Lunney | 2013-11-16 01:36:34 | Re: checking if sequence exists |