Data cleanup in x++

   public void process()

{

    DictTable dictTable = new DictTable(tablenum(MyTable));

 

    if (dictTable && dictTable.enabled())

    {

        str sqlTableName = dictTable.name(DbBackend::Sql);

        SqlDataDictionary sqlTable = new SqlDataDictionary();

 

        if (sqlTable.tableExist(sqlTableName))

        {

            ttsbegin;

            new SqlDataDictionaryPermission(methodstr(SqlDataDictionary, tableTruncate)).assert();

            sqlTable.tableTruncate(tablenum(MyTable), false);

            CodeAccessPermission::revertAssert();

            ttscommit;

        }

        Info("Data clean");

    }


}

Comments

Popular posts from this blog

Assembly reference containing type is not referenced, Object 'CLRObject' could not be created

Extract data of PO from the System in Ax 2012

Send email using .Net framework