AXForum  
Вернуться   AXForum > Microsoft Dynamics AX > DAX Blogs
DAX
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 18.12.2007, 20:40   #1  
Blog bot is offline
Blog bot
Участник
 
25,475 / 846 (79) +++++++
Регистрация: 28.10.2006
axStart: SQL Synchronize trouble, work around
Источник: http://axstart.spaces.live.com/Blog/...C0A0!206.entry
==============


A lot of time the ID of a table or field in the AOT changes (because it moved to a different layer).
When we want to synchronize the data dictionary, AX asks us if it is OK to drop the table. This will result in loss of data. The problem is that the SQLDictionary in the database has still the old ID (SQLDictionary ? see other blog on this site). So in case the dictionary ID change, we also have to correct the SQLDictionary. 
I hoop this small AX job will help you out to solve this. Be aware this is completely not MS best practice, but it works in all my projects J
Note: It is posible that you run into a scenario, that the script updates a record that violate the primary index on this table.

X++:
/* Beware that if you use this script, your database can get corrupted.  
** This will be the case if table ID & Field ID are used like a reference in the Data model  
** an example is Document management Module  
** The only purpose of this script is to avoid dropping of tables when code has changed from Layer  
*/  
static void updateSQLDictionary(Args _args)  
{  
    SQLDictionary   dictionary;  
    str             tableName;  
    int             AOTTableID, AOTFieldID;  
    TreeNode        treeNode;  
    boolean         doTable;  
    ;  
    ttsbegin;  
    while select forupdate dictionary order by tabid,fieldId where dictionary.flags == false  
    {  
        if(dictionary.fieldId == 0)  
        {  
            print dictionary.name;  
            treeNode     = TreeNode::findNode('\data dictionary\tables\'+dictionary.name);  
            if (treeNode)  
            {  
                tableName = dictionary.name;  
                AOTTableID = treeNode.applObjectId();  
   
                if(AOTTableID != dictionary.tabId)  
                {  
                    info(strfmt('risk at Table', dictionary.name));  
                    if(box::yesNo('Fix it?',DialogButton::No))  
                    {  
                        //repair;  
                        dictionary.tabId = AOTTableID;  
                        dictionary.update();  
                    }  
                }  
            }  
        }  
        else  
        {  
            //field  
            treeNode     = TreeNode::findNode('\data dictionary\tables\fields\'+dictionary.name);  
            if (treeNode)  
            {  
                 AOTFieldID = treeNode.applObjectId();  
                 if((AOTTableID != dictionary.tabId) || (AOTFieldID != dictionary.fieldId ))  
                 {  
                    info(strfmt('risk at Table %1 Field %2',tableName, dictionary.name));  
   
                    if(box::yesNo('Fix it? (prease also yes if Table ID is changed or you press yes in a other dimension field',DialogButton::No))  
                    {  
                        //repair, also repair when table ID is changed and field ID not.  
                        dictionary.tabId = AOTTableID;  
                        dictionary.fieldId = AOTFieldID;  
                        dictionary.update();  
                    }  
                }  
             }  
        }  
    }  
    if(box::okCancel('Operation completed, Last warning press Cancel to abort',DialogButton::Cancel))  
    {  
        ttscommit;  
    }  
    else  
    {  
        ttsabort;  
    }  
}


Источник: http://axstart.spaces.live.com/Blog/...C0A0!206.entry
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
Dynamics AX: SQL Sever 2008 - Performance with Dynamics AX 2009 - Resource Governor Blog bot DAX Blogs 0 23.01.2009 22:05
axStart: How to restore an AX 3.0 SQL 2000 backup in sql 2005 Blog bot DAX Blogs 0 12.02.2008 15:10
axStart: How to work with big projects with multi add-ons Blog bot DAX Blogs 0 30.12.2007 16:30
Dynamics AX: SQL Server, Heart of Dynamics AX Blog bot DAX Blogs 0 13.07.2007 18:00
aEremenko: Диагностика проблем при установке Microsoft Dynamics Ax 4.0 на Microsoft SQL Server 2005 Blog bot DAX Blogs 0 28.10.2006 16:01

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 03:31.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.