static void getNextRecIdAX40(Args _args)
{
//Table that stores record ids details for tables
SystemSequences systemSequences;//Class that handles Record id generation
SystemSequence systemSequence = new SystemSequence();
;select firstonly systemSequences where systemSequences.tabId == tableNum(CustTable);systemSequence.suspendRecIds(systemSequences.tabId);
info(strFmt(‘Next record id: %1’, systemSequence.reserveValues(systemSequences.minVal, systemSequences.tabId)));
systemSequence.removeRecIdSuspension(systemSequences.tabId);
}
static void getNaxtRecIdAX30(Args _args)
{
SystemSequence systemSequence;
;systemSequence = new SystemSequence();systemSequence.flushCache();
systemSequence.setCacheSize(30)
info(strFmt(‘Buffer size: %1’, systemSequence.getCacheSize()));
info(strFmt(‘Next record id: %1’, systemSequence.nextVal();));
}
CREATE PROCEDURE initFromSMMQuotationTable @DATAAREAID NVARCHAR(3
AS DECLARE @NEXTVAL BIGINT, @ROWCOUNT BIGINT
SELECT ……,
RECID = IDENTITY(BIGINT,0,1) AS QUOTATIONID —Assign an IDENTITY column with a starting value of 0 incremented by 1
INTO #TEMP
FROM DEL_SMMQUOTATIONTABLE WHERE QUOTATIONSTATUS = 0 —SMMQuotationStatus::InProcess
SELECT @NEXTVAL=NEXTVAL —Retrieve the next value for RECID for this table (by TABID)
FROM SYSTEMSEQUENCES
WITH(UPDLOCK, HOLDLOCK) WHERE ID = -1 AND TABID = 1967
INSERT INTO SALESQUOTATIONTABLE
(column-list)
SELECT ……,
RECID = QUOTATIONID+@NEXTVAL —When we insert into the permanent table, we add the temporary table‟s IDENTITY column to the next value retrieved from SYSTEMSEQUENCES
FROM #TEMP
SELECT @ROWCOUNT = COUNT(*) FROM #TEMP
UPDATE SYSTEMSEQUENCES —We update SYSTEMSEQUENCES to reflect the number of rows that we have added to this table
SET NEXTVAL=NEXTVAL + @ROWCOUNT
WHERE ID = -1 AND TABID = 1967
GO
Hi. I\’m new to AX and find your log invaluable. Thank you.What purpose does RecID now serve that wouldn\’t have been better implemented in 4.0 as an identity column?
LikeLike
Hi,
RecId is not only unique for a table in AX 4.0 but what MS has does is that the management of RecIds is in the hands of AX and not SQL server. This they have done for better performance and also re-usability. That is if any previous record has been deleted and later you see that you want to reuse the RecIds you can do so. System has a way of cleaning up the unused system sequences…
Thats why MS has not made it an identity column…
LikeLike