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

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Querying a Record that has been inserted, but not yet Committed to SQL

(0) ShareShare
ReportReport
Posted on by 204

Hi Guys,

I am trying to debug some code.  I have an outer scope like this:

ttsbegin;

mytable.insert();

myTable::myTableMethod();

ttscommit;

the method is like this

STATIC void myTableMethod()

While Select From myTable Where (certain records that were just inserted in the outer scope)

{

do stuff

}

When I stop the debugger while i am in my While Select statement.  I can see the recId's of the records in myTable that were JUST inserted, but when I go into SQL server, i cannot see these records...?  Im assuming this is because they were not yet committed.   How is it that the While Select Query is able to see them?    This is standard code actually. BomCalcTrans.updateReNumberOprNum.  I am mostly interested in understanding the concepts behind how AX can find the records, but I cannot.  Maybe i have a misunderstanding of something.  Any help would be appreciated. Thanks!

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Chaitanya Golla Profile Picture
    17,225 on at
    RE: Querying a Record that has been inserted, but not yet Committed to SQL

    Hi,

    As you stated, as the transaction is not committed generated recordId is not saved. RecordIds are maintained in system table by name SystemSequences by holding the offset in NextVal field.

    Please refer below links which provides better insights:

    (Insight Into Record IDs)

    sumitsaxfactor.wordpress.com/.../insight-into-record-ids

    (Record IDs in AX 2012 - Though its on AX2012 explanation holds good, except for model database)

    deepakdyanmicsax.blogspot.com/.../record-ids-in-ax-2012_5.html

  • Suggested answer
    Daniel Weichsel Profile Picture
    on at
    RE: Querying a Record that has been inserted, but not yet Committed to SQL

    In your example, the record actually does exist in SQL Server, but transaction isolation levels can prevent other transactions from seeing it until it is committed.  AX uses a read committed snapshot isolation level to achieve this, and probably your direct SQL query is using a similar isolation level.

    You can see these records even before they are committed by using query hints.  For example:

    SELECT * FROM MyTable WITH (NOLOCK)


    is one such way to see these uncommitted records.  It can be very useful when debugging and stepping through X++ code!

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Tocauer Profile Picture

Martin Tocauer 4

#2
Community Member Profile Picture

Community Member 2

#2
Nayyar Siddiqi Profile Picture

Nayyar Siddiqi 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans