Re: Odd behavior with 'currval' - Mailing list pgsql-general

From Steven Hirsch
Subject Re: Odd behavior with 'currval'
Date
Msg-id alpine.DEB.2.20.1802081347290.5809@z87
Whole thread Raw
In response to Re: Odd behavior with 'currval'  (Adrian Klaver <adrian.klaver@aklaver.com>)
Responses Re: Odd behavior with 'currval'
List pgsql-general
On Thu, 8 Feb 2018, Adrian Klaver wrote:

>>> SELECT currval('udm_asset_type_definition_id_seq');
>
> Arrgh my mistake, the above should have been
>
> SELECT currval('udm_asset_type_definition_def_id_seq');

[Code: , SQL State: 55000]  ERROR: currval of sequence 
"udm_asset_type_definition_def_id_seq" is not yet defined in this session

Which is what I'd expect at the psql command line.

In real-life, I am calling from JDBC in a single session - in fact, from 
inside a single transaction.

I will post the JDBC code as soon as I can cut it down to the pertinent 
area.

Also, since you request it:

[hirschs@ui24-lin ~]$ psql -d asset_registry -U hirschs
psql (9.6.5)
Type "help" for help.

asset_registry=# \d udm_asset_type_definition_def_id_seq
       Sequence "main.udm_asset_type_definition_def_id_seq"
     Column     |  Type   |                Value
---------------+---------+--------------------------------------
  sequence_name | name    | udm_asset_type_definition_def_id_seq
  last_value    | bigint  | 21
  start_value   | bigint  | 1
  increment_by  | bigint  | 1
  max_value     | bigint  | 9223372036854775807
  min_value     | bigint  | 1
  cache_value   | bigint  | 1
  log_cnt       | bigint  | 32
  is_cycled     | boolean | f
  is_called     | boolean | t

To me, the greater mystery is why 'pg_get_serial_sequence' is unable to 
find that sequence when invoked by table + column.


-- 


pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: Odd behavior with 'currval'
Next
From: Adrian Klaver
Date:
Subject: Re: Odd behavior with 'currval'