web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Misalignment NextVal SYSTEMSEQUENCES, TabId USERDATAAREAFILTER and SYSCOMPILEILTABLE. What is the specific reason?

(0) ShareShare
ReportReport
Posted on by 50

Hi all,

I verified (in multiple environments) that if I use a method like this one below, with the transact-SQL SET NOCOUNT ON, I obtain, systematically, while accessing clients or while running CIL Incremental compilation, a misalignment on the SYSTEMSEQUENCES table only for the USERDATAAREAFILTER and SYSCOMPILEILTABLE values, the NextVal is increased to MaxVal, wrongly.

Consequences: the users are stopped at AX starting (very bad !). Incremental CIL cannot be executed. 

15500.untitled.png

public static server void ExecuteQueryUpdate()
{
    Connection connection = new Connection();
    Statement  statement  = connection.createStatement();
    str        query;
    ;

    query = @"      SET NOCOUNT ON
                    ;
                    TRUNCATE TABLE Table1
                    ;
                    INSERT INTO [dbo].[Table1]
                               ([FIELD1],[DATAAREAID],[RECVERSION],[PARTITION],[RECID])
                         VALUES
                               ('ciao', 'dat', 1, 5637144576, 1)
                    ;
                    INSERT INTO [dbo].[Table1]
                               ([FIELD1],[DATAAREAID],[RECVERSION],[PARTITION],[RECID])
                         VALUES
                               ('ciao', 'dat', 1, 5637144576, 2)
                    ;
                    --INSERT 3 
		    ;
                    --UPDATE 1
		    ;
                    --INSERT 4
		    ;
                    -- etc.. ";
    
    new SqlStatementExecutePermission(query).assert();
    
    statement.executeUpdate(query);
    
    CodeAccessPermission::revertAssert();
}

Note: the method works correctly and executes the SQL statement correctly.

Important: please note that if I use the same query, with SET NOCOUNT OFF, nothing about happens. 

Any ideas for the specific reason?

*This post is locked for comments

I have the same question (0)
  • Mea_ Profile Picture
    60,284 on at

    First of all you should rethink your solution. There are bunch of reasons why you should not use direct SQL and issues like this is one of them.

    However, if you want to keep playing with it you need to maintain nextvalue manually because AX knows nothong about these inserts, so may allocate recid that you already used.

  • Giuseppe Scaltrito Profile Picture
    50 on at

    Thanks ievgen, I know, I should not use direct SQL. I have already fixed manually the nextValue in SystemSequences. However I'm table owner and I have complete control of this object, so do you have any idea about the problem in this specific case? I found a lot of post on-topic, without answer. (e.g. community.dynamics.com/.../198082) I want to know the cause, no the solution. Thanks in advance.

  • Suggested answer
    Brandon Wiese Profile Picture
    17,788 on at

    I've also recently discovered the SET NOCOUNT ON problem, and also that it is fixed with a SET NOCOUNT OFF.

    I suspect that because AX uses connection pooling, leaving NOCOUNT ON violates an assumption made by the kernel.  In other words, later when it comes along to try to re-use the connection, having NOCOUNT ON breaks an expectation of the kernel, and that results in a code path that corrupts the SYSTEMSEQUENCES record.

    Since we don't have access to the kernel code, there's no easy way to validate.

    Still, it does work to SET NOCOUNT OFF again, leaving the connection in the pool as it was found, which is probably always a good thing.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans