Показать сообщение отдельно
Старый 22.12.2004, 23:19   #5  
AKIS-Falcon is offline
AKIS-Falcon
Ехидна
Аватар для AKIS-Falcon
 
543 / 13 (2) ++
Регистрация: 22.06.2004
Адрес: Pincourt, Montreal, Canada
Вот мой вариант того, что в результате получилось - фактически скрестил два Вадиковских куска кода, спасибо ему кстати еще раз

PHP код:
static void ChangeDimension5(Args _args)
{
    
Dictionary          dictionary = new Dictionary();
    
DictTable           dictTable;
    
DictField           dictField;
    
DictType            dictType;
    
int                 ij;
    
int table_idfield_idtype_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 (
1<= dictionary.tableCnt(); i++)
    {
        
dictTable = new DictTable(dictionary.tableCnt2Id(i));

        if (!
dictTable.isTmp() && !dictTable.isSystemTable() && !dictTable.isView() && ! dicttable.isMap())
        {
            for (
1<= 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::Infostrfmt("%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 почему-то не пошло...

Вот.
__________________
Strictly IMHO and nothing personal.
Сугубо мое персональное мнение, безотносительно к личности оппонента.