From: | Shane Ambler <pgsql(at)Sheeky(dot)Biz> |
---|---|
To: | Alain Roger <raf(dot)news(at)gmail(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: issue with select currval |
Date: | 2007-03-04 16:15:26 |
Message-ID: | 45EAF09E.2020101@Sheeky.Biz |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Alain Roger wrote:
> Hi,
>
> I have a table "photo" where my primary key is name "photo_id" (only serial
> value is stored there).
>
> when i type :
> select currval('photo_photo_id_seq');
>
> the answer is :
> ERROR: relation "photo_photo_id_seq" does not exist
>
> whereas the "relation photo_photo_id_seq" exists
>
> So where is the problem ? should i specify the schema ? (schema is :
> immense)
>
> if i type :
> SELECT photo_id FROM immense.photo ORDER BY photo_id DESC LIMIT 1
> i get what i want (the last serial/index value used by my table)
My guess is that your schema is not in the search path and you need to
fully qualify the name. Try -
select currval('immense.photo_photo_id_seq');
Otherwise double check the spelling of the sequence name (any capitals?)
and the schema that it belongs to.
If you want to avoid typing your schema for everything then add it to
your search path.
SET search_path to immense, public;
SHOW search_path; will tell you what it is currently set to if you want
to check that you won't be removing another schema that is being used.
--
Shane Ambler
pgSQL(at)Sheeky(dot)Biz
Get Sheeky @ http://Sheeky.Biz
From | Date | Subject | |
---|---|---|---|
Next Message | Garry Saddington | 2007-03-04 16:16:08 | Re: date format |
Previous Message | David Lowe | 2007-03-04 16:02:05 | Re: Support for idempotent schema changes? |