Вот мой вариант того, что в результате получилось - фактически скрестил два Вадиковских куска кода, спасибо ему кстати еще раз
PHP код:
static void ChangeDimension5(Args _args)
{
Dictionary dictionary = new Dictionary();
DictTable dictTable;
DictField dictField;
DictType dictType;
int i, j;
int table_id, field_id, type_id;
str execstr;
XppCompiler xppCompiler = new XppCompiler();
extendedTypeId parentTypeId(extendedTypeId _typeId)
{
DictType parentType = new DictType(_typeId);
ExtendedTypeId parentId;
;
while (parentType)
{
parentId = parentType.id();
parentType = new DictType(parentType.extend());
}
return parentId;
}
;
for (i = 1; i <= dictionary.tableCnt(); i++)
{
dictTable = new DictTable(dictionary.tableCnt2Id(i));
if (!dictTable.isTmp() && !dictTable.isSystemTable() && !dictTable.isView() && ! dicttable.isMap())
{
for (j = 1; j <= dictTable.fieldCnt(); j++)
{
dictField = new DictField(dictTable.id(), dictTable.fieldCnt2Id(j));
if (!dictField.isSystem())
{
if (dictField.baseType() == Types::String)
{
//if (parentTypeId(dictField.id()) == extendedtypenum(Num))
dictType = new DictType(dictField.typeId());
type_id = dictfield.typeId();
if (!dictType)
warning (strfmt("%1.%2 - No Type for the Field", dictTable.name(), dictField.name()));
else
if(dictField.typeId() == typeid(Dimension) || dictField.typeId() == 132) // Dimension
{
infolog.add(Exception::Info, strfmt("%1, %2, %3, %4, %5", dictTable.name(), DictField.name(), dicttype.name(), dictfield.typeid(), typeid(Dimension)));
execstr = strfmt('void updatejob() {%1 t; ttsbegin; while select forupdate t where t.%4[5] like "%5" { t.%2[5] = "%3"; t.update(); } ttscommit;}',
dicttable.name(),
dictfield.name(),
'10',
dictfield.name(),
'*');
info (execstr);
if (xppCompiler.compile(execstr))
{
info ("ok");
runbuf(execstr);
}
else
error ("error");
}
}
}
}
}
}
}
Комментарии:
1. Как видно, тип у меня текстовый, так что никаких доппроверок не делаю
2. Не стал заморачиваться с длинным наследованием типа "внук-правнук" и пр. Ограничился только прямым
3. Немного поменял сам код, изменяющий значения полей - update record_setting почему-то не пошло...
Вот.