SQL Sequence next value for

Posts   
 
    
BDN79
User
Posts: 1
Joined: 21-Feb-2018
# Posted on: 21-Feb-2018 11:44:56   

Hi,

in our company we want to use a field in our SQL Server database as PK , filled in with NEXT VALUE FOR [schema].[sequence]

Can anybody explain me how i should configure my LLBLGen project so that i can re-fetch my record after saving? I can't use SCOPE_IDENTITY or @@IDENTITY, they give an error.

I f i use no sequence I always get NULL as value for this field.

TIA

BDN79

version 5.3

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 21-Feb-2018 17:36:53   

This will work if you define a sequence in SQL Server. (2014+). Then select the sequence in the mapping (instead of SCOPE_IDENTITY).

If you use model first, you can let the designer create the sequences and automap them for you. Make sure you have the following Project settings in the llblgen pro designer set to the following values:

Entity Model -> Model First Development -> Prefer system sequences over schema sequences if applicable

set to FALSE (so unchecked)

and Entity Model -> General -> Auto assign sequences to integer pks

set to TRUE (so checked)

If you're using database first, you have to define the sequences in the database schema. In that case, define them using a pattern, and make sure the pattern matches the setting Entity Model -> Database First Development -> Sequence name matching pattern.

Frans Bouma | Lead developer LLBLGen Pro