In D365 RecID there is a SQL system sequence now. SQL itself maintains the IDs. I found a post on this topic.
Using SQL commands described there, I created an X++ method in order to get the sequence name of the table.
It can be useful if you develop a data upgrade script and it is needed to align the sequence when data is moved ‘as is’ to the target D365 table.
public str getSequenceProcedureName(TableName _tableName)
{
str
result;
str
ret;
TableId tableId;
if (this.isTablePresent(_tableName))
{
str sqlQuery = strFmt(@"
SELECT ID from TABLEIDTABLE
JOIN sys.sequences ON
sys.sequences.name = CONCAT('SEQ_', TABLEIDTABLE.ID)
WHERE TABLEIDTABLE.NAME =
'%1'",
_tableName);
result = ReleaseUpdateDB::statementExeQuery(sqlQuery);
if (result)
{
tableId = str2Int(result);
if (tableId)
{
ret = strFmt('SEQ_%1',tableId);
}
}
}
return ret;
}
No comments:
Post a Comment