Re: Odd behavior with 'currval'

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Steven Hirsch <snhirsch(at)gmail(dot)com>, pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Odd behavior with 'currval'
Date: 2018-02-08 18:47:57
Message-ID: 558062c9-1167-f0c7-eed0-c71eb9edf5bd@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 02/08/2018 10:45 AM, Steven Hirsch wrote:
> On Thu, 8 Feb 2018, Melvin Davidson wrote:
>
>> I believe your problem is in your usage.
>> In order for currval(regclass) to work, you must first do a
>> SELECT nextval(regclass) in your _current transaction_!
>>
>> https://www.postgresql.org/docs/9.6/static/functions-sequence.html
>
> I AM doing that.  It is returning zero.  The code is identical to that
> used in all other tables in the schema - all of them work.  This one
> does not - unless I use the INSERT .. RETURNING ..  approach.
>
> I suspect the weirdness with the sequence not being found is part of the
> underlying problem.

I suspect that also, hence my previous suggestion:

\d udm_asset_type_definition_def_id_seq

This should show whether the sequence is 'owned' by the table.column.

>
>

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Steven Hirsch 2018-02-08 18:54:08 Re: Odd behavior with 'currval'
Previous Message Steven Hirsch 2018-02-08 18:45:38 Re: Odd behavior with 'currval'