woensdag 16 mei 2012

List tables with changed data as of certain date

 

static void ADU_BMS_TableDataChanged(Args _args)
{
    TableId         tableId;
    Dictionary      dict = new Dictionary();
    SysDictTable    dictTable;
    Common          common;

    TimeZone        tz;
    TransDate       fromDate;
    UtcDateTime     fromDateTime;

    DataArea        dataArea;
    ;

    fromDate = str2date("16042012", 123);
    fromDateTime = datetobeginUtcDateTime(fromDate, tz);

    info(strfmt("Tables with changed data as of %1", fromDateTime));

    while
    select  dataArea
    where   !dataArea.isVirtual
    {
        changeCompany (dataArea.Id)
        {
            // Clear used variables
            tableId     = 0;
            dictTable   = null;
            common      = null;

            // Actions for company
            tableId = dict.tableNext(0);

            while( tableId)
            {
                dictTable = new DictTable(tableId);

                if (!dictTable.isTmp() && !dictTable.isMap() && !dictTable.isView())
                {
                    common = dictTable.makeRecord();

                    select  count(RecId)
                    from    common
                    where   common.createdDateTime  >= fromDateTime
                        ||  common.modifiedDateTime >= fromDateTime;

                    if (common.RecId)
                    {
                        info(strfmt("%1:%2 - %3 changes", dataArea.Id, dictTable.name(), common.RecId ));
                    }
                }

                tableId = dict.tableNext(tableId);
            }

        }
    }

}

Geen opmerkingen:

Een reactie plaatsen