Skip to main content

One post tagged with "xpp"

View All Tags

Truncate a table using X++

· One min read
Max Nguyen
FinOps Ranger

We can use the tableTruncate method from SqlDataDictionary to truncate a table in FinOps, useful for a huge SQL table.

public static void main(Args _args)
{
DictTable dictTable = new DictTable(tablenum(KA_TBYTDStaging));

if (dictTable && dictTable.enabled())
{
str sqlTableName = dictTable.name(DbBackend::Sql);
SqlDataDictionary sqlTable = new SqlDataDictionary();

if (sqlTable.tableExist(sqlTableName))
{
new SqlDataDictionaryPermission(methodstr(SqlDataDictionary, tableTruncate)).assert();
sqlTable.tableTruncate(tablenum(KA_TBYTDStaging), false);
CodeAccessPermission::revertAssert();
}
}
}