Wednesday, February 15, 2012

OMB OWB TCL Repair NULL.

During the migration constants with the value NULL where migration as 'NULL' (with quotes). I create a script to replace them trough the whole repository with TO_CHAR(NULL).
############################################################
#                                                          #
# Set Expression OWB Repair NULL                           #
#                                                          #
# During Migration from OWB10.1 to 11gR2 an Expression     #
# NULL is migrated as 'NULL' making it a VARCHAR(4)        #
# This script repairs it for all Operators called:         #
# - C_STANDAARD                                               #
#                                                          #
# (C) Ciber Nederland John Minkjan                         #
#                     http:\\OMB101.blogspot.com           # 
#        V001    Init Version                              #
#        V002    Validated against OWB11gR2                #
#                                                          #
############################################################

#Disconnect if connected
catch {
    OMBDISCONNECT;
    };
   
# Connect
OMBCONNECT ****/*******@*******:1521:OWB_POC \
USE  WORKSPACE '*******';

# Set OMBPROMPT
set OMBPROMPT ON;

# Set ProjectList
set ProjectList [list ********];
foreach Project $ProjectList {
    OMBCC '$Project'
    set ModuleList [OMBLIST ORACLE_MODULES]
    #set ModuleList [list DM_DNI]
    foreach Module $ModuleList {
        OMBCC '$Module';
        set MappingList [OMBLIST MAPPINGS]
        foreach Mapping $MappingList {
            set OperatorList [OMBRETRIEVE MAPPING '$Mapping' GET OPERATORS];
            foreach Operator $OperatorList {
                    if {$Operator == "C_STANDAARD"} {
                        puts  "$Module - $Mapping - $Operator - ";
                        set GroupsList [OMBRETRIEVE MAPPING '$Mapping' \
                                            OPERATOR '$Operator' \
                                            GET GROUPS];
                        foreach Group $GroupsList {
                            puts  "$Module - $Mapping - $Operator - $Group ";
                            set AttributeList [OMBRETRIEVE MAPPING '$Mapping' \
                                                OPERATOR '$Operator' \
                                                GROUP '$Group' \
                                                GET ATTRIBUTES]
                            foreach Attribute $AttributeList {
                                puts  "$Module - $Mapping - $Operator - $Group - $Attribute ";
                                set Expression [OMBRETRIEVE MAPPING '$Mapping' \
                                                OPERATOR '$Operator' \
                                                GROUP '$Group' \
                                                ATTRIBUTE '$Attribute' \
                                                GET PROPERTIES (EXPRESSION)]
                                puts "Current Expression: $Expression"
                                if {$Expression  == "\'NULL\'"} {
                                    puts "BINGO"
                                    puts [OMBALTER MAPPING '$Mapping' \
                                            MODIFY ATTRIBUTE '$Attribute' \
                                            OF GROUP '$Group' \
                                            OF OPERATOR '$Operator'  \
                                            SET PROPERTIES (EXPRESSION) VALUES('TO_CHAR(NULL)')]
                                    set Expression [OMBRETRIEVE MAPPING '$Mapping' \
                                                    OPERATOR '$Operator' \
                                                    GROUP '$Group' \
                                                    ATTRIBUTE '$Attribute' \
                                                    GET PROPERTIES (EXPRESSION)]
                                    puts "Current Expression: $Expression"
                                    OMBCOMMIT;
                                }
                                };
                            };
                        };
                    };
            };
        OMBCC '..';
        };
    OMBCOMMIT;
    OMBCC '..';
    };   
OMBSAVE;


Download found here: Repair NULL

Till Next Time

No comments:

Post a Comment