From: | will trillich <will(at)serensoft(dot)com> |
---|---|
To: | PostgreSQL-General <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Re: Rules, views, sequences and returned values |
Date: | 2001-03-23 16:39:02 |
Message-ID: | 20010323103902.A20101@mail.serensoft.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Fri, Mar 23, 2001 at 09:53:49AM -0500, Gregory Wood wrote:
> > I have a table and want to make a view updateable with rules. Table has a
> > sequence that creates default value to primary key when inserting.
> >
> > And now the question: Is it posible to return value of primary key from
> > rule of inserting with NEW? Is that value what i would get from extern
> > calling to insert, instead of OID?.
>
> SELECT currval('seq-table-name_seq-field-name_seq');
>
> where seq-table-name is the name of your table (not the view), and
> seq-field-name is the name of the primary key.
i'm sure there's a reason for this--
psql=> select currval('mytable_afield_seq') ;
ERROR: mytable_afield_seq.currval is not yet defined in this session
but i'll be darned if i can figure out what it is. (after one
call to "nextval()" currval() works fine, of course.) someone hit
me with a clue stick!
--
It is always hazardous to ask "Why?" in science, but it is often
interesting to do so just the same.
-- Isaac Asimov, 'The Genetic Code'
will(at)serensoft(dot)com
http://newbieDoc.sourceforge.net/ -- we need your brain!
http://www.dontUthink.com/ -- your brain needs us!
From | Date | Subject | |
---|---|---|---|
Next Message | will trillich | 2001-03-23 16:41:46 | Re: from string to table...? |
Previous Message | Tom Lane | 2001-03-23 16:34:09 | Re: Lost Trigger(s)? |