#1 2021-04-26 17:40:42

tbo
Member
Registered: 2015-04-20
Posts: 349

Set start value of RowID

mORMot 2, SQLite

I would like to set the initial value of the RowID. When the user adds the first record, the value for RowID should be 1000 when executing Add(..., True) via the ORM. Background: When creating the table, I create records that the user cannot change/delete. For these system records I want to reserve a range of 1..999. How can I achieve this?

I thought I had read a solution before, but I can't find it anymore.

With best regards
Thomas

Last edited by tbo (2021-04-26 17:41:35)

Offline

#2 2021-04-26 18:11:47

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,548
Website

Re: Set start value of RowID

You can force the RowID when adding a record.

So the easiest is to check at startup (or at first add operation) if IRestOrm.TableHasRows() = false then force RowID=1000 for the first add.
It will have the advantage of working with all kind of DB backends.

Offline

Board footer

Powered by FluxBB