1. Mass data update

    Article: AN0001872Updated: 23.09.2018

    In some cases we need to update all the data in the class. We could update the records one by one by means of the object OG.DataRow, however, this would be quite slow. In such cases it is better to update the data directly in the database by means of SQL - OG.Sql.RunSql(sql).

    Below script will update values in column 'my_calc_column' to values from column 'my_integer_column' minus 5.

    Místo použití skriptu: Jakýkoli objekt obsahující skript

    var m = OG.Model.GetByCode('my_model');
    var cl = m.ClassDefs['my_class'];
    var colInt = cl.Columns['my_integer_column'];
    var colCalc = cl.Columns['my_calc_column'];

    var sql = 'update datarow' + cl.Id + ' set ' + colCalc.DBColumnName + ' = ' + colInt.DBColumnName + ' - 5';