Re: Redirect sequence access to different schema

From: Joe Conway <mail(at)joeconway(dot)com>
To: Magnus Reftel <magnus(dot)reftel(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Redirect sequence access to different schema
Date: 2010-07-25 21:13:17
Message-ID: 4C4CA8ED.2020906@joeconway.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 07/25/2010 12:01 PM, Magnus Reftel wrote:
> create view myseq as select * from other_schema.foo_id_seq;
>
> but when I run "select nextval('myseq');" I get an error saying that
> myseq "is not a sequence". What other options are there?

It isn't clear (to me, at least) what you are trying to accomplish, but
does this do what you want?

create schema other_schema;
create SEQUENCE other_schema.foo_id_seq;

select current_schema;
current_schema
----------------
public
(1 row)

select nextval('other_schema.foo_id_seq');
nextval
---------
1
(1 row)

select nextval('other_schema.foo_id_seq');
nextval
---------
2
(1 row)

Joe

--
Joe Conway
credativ LLC: http://www.credativ.us
Linux, PostgreSQL, and general Open Source
Training, Service, Consulting, & 24x7 Support

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Magnus Reftel 2010-07-26 07:49:21 Re: Redirect sequence access to different schema
Previous Message Lyle 2010-07-25 19:25:23 Re: DROP CONSTRAINT IF EXISTS - simulating in 7 and 8?