Autoinc in postgresql

Hi,
in PostgreSQL i have two ways to create autoinc field.

create table autoinc1(id BIGINT GENERATED ALWAYS AS IDENTITY, name varchar(80)) ;
or
create table autoinc2(id BIGSERIAL , name varchar(80)) ;
My schema is still manually build, imported from Zen.
2nd one creates sequense, but first one doens't.
With always as identity I get error sequnse not found if I have automapping on
this work, but if I uncomment automapping it want's sequense.
Is there attribute which could tell that this entity is using " GENERATED ALWAYS AS IDENTITY"
[ Entity ]
// [ automapping]
[ table( 'kassaldo' ) ]
[ Id( 'Fid', TIdGenerator.IdentityOrSequence ) ]
TInHouseCreditRow = class
private
[ Column( 'avain' ,[TColumnProp.Required,TColumnProp.NoInsert, TColumnProp.NoUpdate]) ]
Fid: integer;

Hi!
It should be automatic, I'm not sure why you are having issues with it.

With PostgreSQL, if you have an attribute [Sequence] defined in your mapping, then it will use it to generate a new id.

If there is no Sequence attribute, then Aurelius will execute an INSERT statement with a RETURNING clause to retrieve the id value generated internally by the database, regardless on how it does it.

Could it be that Automapping generates Sequence ?

Yes, Automapping does generate a sequence named SEQ_<tablename>.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.