home *** CD-ROM | disk | FTP | other *** search
/ Pro Intralink 3.1 / Pro Intralink v3.1.iso / migration / migrate_chk.tcl < prev    next >
Encoding:
Text File  |  2001-11-27  |  17.5 KB  |  641 lines

  1. #
  2. # 07-MAR-00  I4.0.0.25    APB    $$1   Initial submission
  3. #
  4. #########################################################################
  5. #
  6. # Checking migration status
  7. #
  8.  
  9. #########################################################################
  10. #  Procedure:
  11. #      CDVersion - gets version of current CD
  12. #
  13. proc GetCDVersion {} {
  14.     global PathDlmtr
  15.     set SourceName "applrev.h"
  16.     set SourceFile [open [file dirname [info script]]${PathDlmtr}${SourceName}]
  17.     return [lindex [gets $SourceFile] 2]
  18. }
  19.  
  20. #########################################################################
  21. #  Procedure:
  22. #      OracleConnect - check database connection.
  23. #
  24. #  Input parameters:
  25. #      UserPwd - "username/password"
  26. #
  27. proc OracleConnect {UserPwd} {
  28.    global LogMsg StatString ilnk_platform errorCode
  29.    set PlusOut ""
  30.    set errorCode ""
  31.  
  32.    set FullCmdTxt "WHENEVER OSERROR EXIT 1
  33.    exit
  34.    "
  35.    catch {
  36.      exec $ilnk_platform(SqlplusPrg) -s $UserPwd << $FullCmdTxt
  37.    } PlusOut
  38.  
  39.    if {($errorCode != "") && ($errorCode != "NONE")} {
  40.       set ErrMsg "\nProgramm $ilnk_platform(SqlplusPrg) returned nonzero code:\n  $errorCode\n\n"
  41.       set LogMsg "$ErrMsg\n\n$PlusOut\n\n"
  42.       set StatString "Status \"CANNOTCONNECT\"\n"
  43.       error $LogMsg $StatString "STOP"
  44.    }
  45.    return $PlusOut
  46. }
  47.  
  48. #########################################################################
  49. #  Procedure:
  50. #      ConvertCheck - check if the database is a convert database.
  51. #
  52. #  Input parameters:
  53. #      UserPwd - "username/password"
  54. #
  55. proc ConvertCheck {UserPwd} {
  56.    global LogMsg StatString ilnk_platform errorCode
  57.  
  58.    set SqlHead "set head off"
  59.    set SqlCmd "$SqlHead
  60.    SELECT count(*) FROM dba_rollback_segs
  61.    WHERE TABLESPACE_NAME='PTC_HUGERBS_TBSP';
  62. "
  63.    set seg_num [RunSqlplus ${UserPwd} $SqlCmd]
  64.  
  65.    if {$seg_num != 0} {
  66.       set LogMsg "\nMigration is not supported for Pro/Convert database\n\n"
  67.       set StatString "Status \"NOTSUPPORTED\"\n"
  68.       error $LogMsg $StatString "STOP"
  69.    }
  70. }
  71.  
  72. #########################################################################
  73. #  Procedure:
  74. #      RunSqlplus - run SQL*Plus with connection by $UserPwd and executes
  75. #                   all commands in $CmdTxt.
  76. #
  77. #  Input parameters:
  78. #      UserPwd - "username/password"
  79. #      CmdTxt  - commands to execute
  80. #
  81. #  Returned Value:
  82. #      Return SQL*Plus output.
  83. #
  84. proc RunSqlplus {UserPwd CmdTxt} {
  85.    global LogMsg StatString ilnk_platform errorCode
  86.    set PlusOut ""
  87.    set errorCode ""
  88.  
  89. set FullCmdTxt "WHENEVER OSERROR EXIT 1
  90. $CmdTxt
  91. exit
  92. "
  93.    catch {
  94.      exec $ilnk_platform(SqlplusPrg) -s $UserPwd << $FullCmdTxt
  95.    } PlusOut
  96.  
  97.    if {($errorCode != "") && ($errorCode != "NONE")} {
  98.       set ErrMsg "\nProgramm $ilnk_platform(SqlplusPrg) returned nonzero code:\n  $errorCode\n\n"
  99.       set LogMsg "$ErrMsg\n\n$PlusOut\n\n"
  100.       set StatString "Status \"SCHEMAERROR\"\n"
  101.       error $LogMsg $StatString "STOP"
  102.    }
  103.    return $PlusOut
  104. }
  105.  
  106. ##########################################################################
  107. # WriteLog - output string into LogFile file without appending
  108. #            newline character. You have to specify it explicitly.
  109. #
  110. # Input parameters:
  111. #    OutputString - Text for output in log file.
  112. #
  113. # Return value:
  114. #    NONE
  115. #
  116. proc WriteLog {OutputString} {
  117.   global LogFile
  118.  
  119.   if {[file exists ${LogFile}] == 1} {
  120.      set log_file [open ${LogFile} "a"]
  121.   } else {
  122.      set log_file [open ${LogFile} "w"]
  123.   }
  124.   puts -nonewline $log_file ${OutputString}
  125.   flush $log_file
  126.   close $log_file
  127. }
  128.  
  129. ##########################################################################
  130. # GetDBCharSet - return current datbase character set.
  131. #
  132. # Input parameters:
  133. #    NONE
  134. #
  135. # Return value:
  136. #    Text string
  137. #
  138. proc GetDBCharSet {} {
  139.     global LogMsg StatString PwdConnectString
  140.  
  141.     set SqlCmd {set pagesize 0
  142.         set feedback off
  143.         set Verify off
  144.         select VALUE from NLS_DATABASE_PARAMETERS where PARAMETER='NLS_CHARACTERSET';
  145. }
  146.  
  147.     set charset [RunSqlplus ${PwdConnectString} $SqlCmd]
  148.  
  149.     set err_rep [OraErrorReport $charset ""]
  150.  
  151.     if {$err_rep != ""} {
  152.         set ErrMsg "\nError during running sqlplus:"
  153.         set LogMsg "$ErrMsg\n\n${err_rep}\n$SqlOut\n"
  154.         set StatString "Status \"SCHEMAERROR\"\n"
  155.         error $LogMsg $StatString "STOP"
  156.     }
  157.     return $charset
  158. }
  159.  
  160. ##########################################################################
  161. # GetCurrentVersion - return current version string accordingly with
  162. #                     information in DB.
  163. #
  164. # Input parameters:
  165. #    NONE
  166. #
  167. # Return value:
  168. #    Text string
  169. #
  170. proc GetCurrentVersion {} {
  171.   global LogMsg StatString PwdConnectString
  172.  
  173. set SqlHead "set pagesize 0
  174.  set feedback off
  175.  set Verify off
  176. "
  177.  
  178. set SqlCmd "$SqlHead
  179.  col CNT format 9990
  180.  select count(*) CNT from PDM.PDM_REVISIONS
  181.  where REVSTATUS=1;
  182. "
  183.   set str_nmb [RunSqlplus ${PwdConnectString} $SqlCmd]
  184.  
  185.   set err_rep [OraErrorReport $str_nmb ""]
  186.  
  187.   if {$err_rep != ""} {
  188.      set ErrMsg "\nError during running sqlplus:"
  189.      set LogMsg "$ErrMsg\n\n${err_rep}\n$SqlOut\n"
  190.      set StatString "Status \"SCHEMAERROR\"\n"
  191.      error $LogMsg $StatString "STOP"
  192.   }
  193.  
  194.   if {[regexp { +1} $str_nmb] != 1} {
  195.      set ErrMsg "\nError: current version is not defined. Check table PDM_REVISIONS."
  196.      set LogMsg "$ErrMsg\n"
  197.      set StatString "Status \"SCHEMAERROR\"\n"
  198.      error $LogMsg $StatString "STOP"
  199.   }
  200.  
  201. set SqlCmd "$SqlHead
  202.  select REVEXE from PDM.PDM_REVISIONS
  203.  where REVSTATUS=1;
  204. "
  205.   set cur_version [RunSqlplus ${PwdConnectString} $SqlCmd]
  206.  
  207.   set err_rep [OraErrorReport $cur_version ""]
  208.  
  209.   if {$err_rep != ""} {
  210.      set ErrMsg "\nError during running sqlplus:"
  211.      set LogMsg "$ErrMsg\n\n${err_rep}\n$SqlOut\n"
  212.      set StatString "Status \"SCHEMAERROR\"\n"
  213.      error $LogMsg $StatString "STOP"
  214.   }
  215.  
  216.   if {$cur_version == ""} {
  217.      set ErrMsg "\nError: current version is not defined."
  218.      set LogMsg "$ErrMsg\n"
  219.      set StatString "Status \"SCHEMAERROR\"\n"
  220.      error $LogMsg $StatString "STOP"
  221.   }
  222.  
  223.   if {[string first "." $cur_version] == -1} {
  224.        #
  225.        # Old style of version numbers
  226.        #
  227.        set cur_release  "${cur_version}"
  228.        set cur_version  "${cur_release}.1.H-01"
  229.   }
  230.   return $cur_version
  231. }
  232.  
  233. ##########################################################################
  234. # VersionCompare - compare two version of dataserver and return result
  235. #
  236. #
  237. # Input parameters:
  238. #    VersionLabel1
  239. #    VersionLabel2
  240. #
  241. # Return value:
  242. #    -1 - VersionLabel1 is older
  243. #     0 - VersionLabel1 and VersionLabel2 are equivalent
  244. #     1 - VersionLabel2 is older
  245. #     2 - Version isn't supported
  246. #
  247. proc VersionCompare {VersionLabel1 VersionLabel2} {
  248.   global LogMsg StatString
  249.   set ErrMsg ""
  250.  
  251.   # General info about labels
  252.  
  253.   set SplitLabel1 [split $VersionLabel1 .]
  254.   set SplitLabel2 [split $VersionLabel2 .]
  255.  
  256.   set LengthLabel1 [llength $SplitLabel1]
  257.   set LengthLabel2 [llength $SplitLabel2]
  258.  
  259.   if {($LengthLabel1 != 5) && ($LengthLabel1 != 3)} {
  260.     set ErrMsg "\nError: Unrecognized version : $VersionLabel1"
  261.     set LogMsg "$ErrMsg\n"
  262.     set StatString "Status \"SCHEMAERROR\"\n"
  263.     error $LogMsg $StatString "STOP"
  264.   }
  265.  
  266.   if {($LengthLabel2 != 5) && ($LengthLabel2 != 3)} {
  267.     set ErrMsg "\nError: Unrecognized version : $VersionLabel2"
  268.     set LogMsg "$ErrMsg\n"
  269.     set StatString "Status \"SCHEMAERROR\"\n"
  270.     error $LogMsg $StatString "STOP"
  271.   }
  272.  
  273.   if {$LengthLabel1 < $LengthLabel2} { return -1 }
  274.  
  275.   if {$LengthLabel1 > $LengthLabel2} { return 1 }
  276.  
  277.   set CompareValue 0
  278.  
  279.   if {$LengthLabel1 == 3} {
  280.     if {[lindex $SplitLabel1 2] != "I-01"} {
  281.       # not supported
  282.       return 2
  283.     }
  284.  
  285.     if {[lindex $SplitLabel2 2] != "I-01"} {
  286.       # not supported
  287.       return 2
  288.     }
  289.  
  290.     if {[string length [lindex $SplitLabel1 0]] < [string length [lindex $SplitLabel2 0]]} {
  291.       return -1
  292.     }
  293.     if {[string length [lindex $SplitLabel1 0]] > [string length [lindex $SplitLabel2 0]]} {
  294.       return 1
  295.     }
  296.     if {[lindex $SplitLabel1 0] < [lindex $SplitLabel2 0]} { return -1 }
  297.     if {[lindex $SplitLabel1 0] > [lindex $SplitLabel2 0]} { return 1 }
  298.     if {[lindex $SplitLabel1 1] < [lindex $SplitLabel2 1]} { return -1 }
  299.     if {[lindex $SplitLabel1 1] > [lindex $SplitLabel2 1]} { return 1 }
  300.   }
  301.  
  302.   if {$LengthLabel1 == 5} {
  303.     for {set i 0} {$i <= 4} {incr i} {
  304.       if {$i == 0} {
  305.     if {[string range [lindex $SplitLabel1 0] 1 end] < [string range [lindex $SplitLabel2 0] 1 end]} {
  306.       set CompareValue -1
  307.       break
  308.     }
  309.     if {[string range [lindex $SplitLabel1 0] 1 end] > [string range [lindex $SplitLabel2 0] 1 end]} {
  310.       set CompareValue 1
  311.       break
  312.     }
  313.       } else {
  314.     if {[lindex $SplitLabel1 $i] < [lindex $SplitLabel2 $i]} {
  315.       set CompareValue -1
  316.       break
  317.     }
  318.     if {[lindex $SplitLabel1 $i] > [lindex $SplitLabel2 $i]} {
  319.       set CompareValue 1
  320.       break
  321.     }
  322.       }
  323.     }
  324.   }
  325.   return $CompareValue
  326. }
  327.  
  328. #########################################################################
  329. # OraErrorReport - get ORACLE program's output and return list of error
  330. #                  messages and their descriptions.
  331. #                  Return emty string, if ORACLE errors were not found.
  332. #
  333. # Input parameters:
  334. #      OraOutput    - ORACLE program's output for testing.
  335. #      NormalErrLst - list of errors, that must be ignored.
  336. #
  337. # Default Values:
  338. #      NormalErrLst = ""
  339. #
  340. proc OraErrorReport {OraOutput {NormalErrLst ""}} {
  341.  
  342.   set ErrorsReport  ""
  343.   set OutputStrngs  $OraOutput
  344.  
  345.   foreach oerr $NormalErrLst {
  346.      regsub -all $oerr ${OutputStrngs} "It is not error" OutputStrngs
  347.   }
  348.  
  349.   if {[regexp {[A-Z][A-Z]+-[0-9][0-9][0-9][0-9]+:} ${OutputStrngs}] == 0} {
  350.      return $ErrorsReport
  351.   }
  352.  
  353.   set ErrorsReport "   List of error messages:\n\n"
  354.   set first_item   1
  355.   set err_lst      ""
  356.  
  357.   while {$OutputStrngs != ""} {
  358.      set eofstr [string first "\n" $OutputStrngs]
  359.  
  360.      if {$eofstr == -1} {
  361.     set msg_str $OutputStrngs
  362.     set eofstr  [string length $OutputStrngs]
  363.      } else {
  364.     set msg_str [string range $OutputStrngs 0 [expr {$eofstr-1}]]
  365.     set eofstr  [expr {$eofstr+1}]
  366.      }
  367.  
  368.      if {[regexp {[A-Z][A-Z]+-[0-9][0-9][0-9][0-9]+:} $msg_str err_desc] == 1} {
  369.     set ErrorsReport "${ErrorsReport}${msg_str}\n"
  370.     if {$first_item == 1} {
  371.        set err_lst $err_desc
  372.        set first_item 0
  373.     } else {
  374.        if {[lsearch -exact $err_lst $err_desc] == -1} {
  375.           lappend err_lst $err_desc
  376.        }
  377.     }
  378.      }
  379.      set eoftext [string length $OutputStrngs]
  380.      set OutputStrngs [string range $OutputStrngs $eofstr $eoftext]
  381.   }
  382.   return ${ErrorsReport}
  383. }
  384.  
  385. #########################################################################
  386. # Main
  387. #
  388.  
  389. set LogMsg ""
  390. set StatString ""
  391. set SizeString "Size 0\n"
  392.  
  393. catch {
  394.   #--------------------------------------
  395.   # General settings
  396.  
  397.   set LogFile [lindex ${argv} 0]
  398.  
  399.   switch $tcl_platform(platform) {
  400.     unix {
  401.       set PathDlmtr    "/"
  402.       set ORA_HOME     $env(ORACLE_HOME)
  403.       set ilnk_platform(SvrMngr)      "$ORA_HOME/bin/svrmgrl"
  404.       set ilnk_platform(SqlplusPrg)   "$ORA_HOME/bin/sqlplus"
  405.       }
  406.     windows {
  407.       set PathDlmtr    "\\"
  408.       set ORA_HOME     $env(ORACLE_HOME)
  409.       if {[file exists "$ORA_HOME/bin/plus33.exe"]} {
  410.           set ilnk_platform(SvrMngr)    "svrmgr23.exe"
  411.           set ilnk_platform(SqlplusPrg) "plus33.exe"
  412.       } else {
  413.           set ilnk_platform(SvrMngr)      "svrmgrl.exe"
  414.           set ilnk_platform(SqlplusPrg)   "sqlplus.exe"
  415.       }
  416.       }
  417.     default  {
  418.       set StatString "Status \"NOTSUPPORTED\"\n"
  419.       set LogMsg "Unsupported tcl_platform(platform)=$tcl_platform(platform)\n"
  420.       error $LogMsg $StatString "STOP"
  421.       }
  422.   }
  423.  
  424.   if {![info exists env(ORA_SYS_PWD)]} {
  425.       set StatString "Status \"NOTSUPPORTED\"\n"
  426.       set LogMsg "Environment variable ORA_SYS_PWD was not set"
  427.       error $LogMsg $StatString "STOP"
  428.   }
  429.  
  430.   set PwdConnectString "system/$env(ORA_SYS_PWD)"
  431.  
  432.   # Check oracle connection
  433.  
  434.   OracleConnect $PwdConnectString
  435.   
  436.   # Check if the running database is a Pro/Convert database
  437.  
  438.   ConvertCheck $PwdConnectString
  439.  
  440.   #*******************************************************************************
  441.   #                  Migration/Update behavior evaluation
  442.   #*******************************************************************************
  443.  
  444.   set CurProiVersion [GetCurrentVersion]
  445.   set CurrentCDVersion [GetCDVersion]
  446.  
  447.   if {([VersionCompare $CurProiVersion "I2.0.0.12.3"] >= 0) &&
  448.       ([VersionCompare $CurProiVersion "I4.0.1.19.6"] == -1)} { 
  449.       #
  450.       # current version between I2.0.0.12.3 (2.0FCS) and I4.0.1.19.6 (3.0FCS) - any 2.x
  451.       #
  452.       set StatString "Status \"MIGRATION\"\n"
  453.   } elseif {([VersionCompare $CurProiVersion "I4.0.1.19.6"] >= 0) &&
  454.       ([VersionCompare $CurProiVersion $CurrentCDVersion] <= 0)} {
  455.       #
  456.       # current version between I4.0.1.19.6 (3.0FCS) and current CD version - any 3.x
  457.       #
  458.       set StatString "Status \"UPDATE\"\n"
  459.   } else {
  460.       #
  461.       # current version is lower than I2.0.0.12.3 (2.0FCS)
  462.       # or higher than current CD version
  463.       #
  464.       set StatString "Status \"NOTSUPPORTED\"\n"
  465.       set LogMsg "Current version of dataserver is: $CurProiVersion\n"
  466.       append LogMsg "Dataserver migration from all versions earlier than I2.0.0.12.3\n"
  467.       append LogMsg "or later than $CurrentCDVersion using this CD is not supported."
  468.       error $LogMsg $StatString "STOP"
  469.   } 
  470.  
  471.   if {[GetDBCharSet] != "UTF8"} {
  472.       #
  473.       # Exceptional situation when migration needed because of DB character set
  474.       #
  475.       set StatString "Status \"MIGRATION\"\n"
  476.   }
  477.  
  478.   #*******************************************************************************
  479.   #             The End of Migration/Update Behavior Evaluation
  480.   #*******************************************************************************
  481.  
  482.   #--------------------------------------
  483.   # Estimate dmp-file size
  484.  
  485.   set ConstSize "1048576"
  486.   set PackageKo "1.1"
  487.  
  488.   set SqlCmd "
  489.     DROP TABLE pdm_temp_estimate_size;
  490.  
  491.     CREATE TABLE pdm_temp_estimate_size (
  492.       owner      VARCHAR2(30),
  493.       table_name VARCHAR2(30),
  494.       tab_size   NUMBER
  495.     );
  496.   "
  497.  
  498.   set SqlOut [RunSqlplus ${PwdConnectString} $SqlCmd]
  499.  
  500.   # ORA-00942: table or view does not exist
  501.   set err_rep [OraErrorReport $SqlOut "ORA-00942"]
  502.  
  503.   if {$err_rep != ""} {
  504.      set ErrMsg "\nError during running sqlplus:"
  505.      set LogMsg "$ErrMsg\n\n${err_rep}\n$SqlOut\n"
  506.      set StatString "Status \"SCHEMAERROR\"\n"
  507.      error $LogMsg $StatString "STOP"
  508.   }
  509.  
  510.   set SqlCmd "set pagesize 0
  511.     set feedback off
  512.     set verify off
  513.     set echo off
  514.     set trim on
  515.     set space 0
  516.     set serveroutput on size 1000000
  517.  
  518.     DECLARE
  519.       v_i        INTEGER;
  520.  
  521.       CURSOR table_list1 IS
  522.     SELECT owner,
  523.            table_name
  524.       FROM dba_tables
  525.      WHERE owner='PDM'
  526.        AND table_name not IN (SELECT m.table_name
  527.                     FROM dba_tab_columns m
  528.                    WHERE m.owner='PDM'
  529.                      AND m.data_type like '%LONG%');
  530.  
  531.       CURSOR table_list2 IS
  532.     SELECT distinct t.owner,
  533.            t.table_name
  534.       FROM dba_tables t,
  535.            dba_tab_columns c
  536.      WHERE t.owner='PDM'
  537.        AND t.owner=c.owner
  538.        AND t.table_name=c.table_name
  539.        AND c.data_type like '%LONG%'
  540.      ORDER BY t.table_name;
  541.  
  542.       CURSOR column_list(tab_name VARCHAR2) IS
  543.     SELECT column_name
  544.       FROM dba_tab_columns
  545.      WHERE owner='PDM'
  546.        AND table_name=tab_name;
  547.  
  548.     BEGIN
  549.     FOR arg IN table_list1 LOOP
  550.       dbms_output.put_line('INSERT INTO pdm_temp_estimate_size SELECT '||chr(39)||arg.owner||chr(39)||','||chr(39)||arg.table_name||chr(39)||',sum(');
  551.       v_i := 0;
  552.       FOR clm IN column_list(arg.table_name) LOOP
  553.     IF v_i <= 0 THEN
  554.       dbms_output.put_line('2+nvl(vsize('||clm.column_name||'),0)+2');
  555.     ELSE
  556.       dbms_output.put_line('+nvl(vsize('||clm.column_name||'),0)+2');
  557.     END IF;
  558.     v_i := v_i + 1;
  559.       END LOOP;
  560.       dbms_output.put_line(') total_size FROM '||arg.owner||'.'||arg.table_name||';');
  561.     END LOOP;
  562.     FOR arg IN table_list2 LOOP
  563.       dbms_output.put_line('ANALYZE TABLE '||arg.owner||'.'||arg.table_name||' COMPUTE STATISTICS;');
  564.       dbms_output.put_line('INSERT INTO pdm_temp_estimate_size SELECT '||chr(39)||arg.owner||chr(39)||','||chr(39)||arg.table_name||chr(39)||',');
  565.       dbms_output.put_line('num_rows*avg_row_len total_size FROM dba_tables WHERE owner='||chr(39)||arg.owner||chr(39)||' AND table_name='||chr(39)||arg.table_name||chr(39)||';');
  566.     END LOOP;
  567.     dbms_output.put_line('COMMIT;');
  568.     EXCEPTION
  569.       WHEN others THEN null;
  570.     END;
  571. /
  572.   "
  573.  
  574.   set SqlOut [RunSqlplus ${PwdConnectString} $SqlCmd]
  575.  
  576.   set err_rep [OraErrorReport $SqlOut ""]
  577.  
  578.   if {$err_rep != ""} {
  579.      set ErrMsg "\nError during running sqlplus:"
  580.      set LogMsg "$ErrMsg\n\n${err_rep}\n$SqlOut\n"
  581.      set StatString "Status \"SCHEMAERROR\"\n"
  582.      error $LogMsg $StatString "STOP"
  583.   }
  584.  
  585.   set AddSqlCmd "
  586.     SELECT ltrim(to_char(sum(com_size),'999999999999999999990'))
  587.       FROM ( SELECT sum(source_size) * $PackageKo com_size
  588.            FROM dba_object_size
  589.           WHERE owner='PDM'
  590.         AND type IN ('PROCEDURE','FUNCTION','PACKAGE','PACKAGE BODY')
  591.           UNION
  592.          SELECT sum(tab_size)
  593.            FROM pdm_temp_estimate_size
  594.           UNION
  595.          SELECT $ConstSize FROM dual);
  596.     DROP TABLE pdm_temp_estimate_size;
  597.   "
  598.  
  599.   set SqlCmd "set pagesize 0
  600.     set feedback off
  601.     set head off
  602.     set term on
  603.     
  604.     $SqlOut
  605.     $AddSqlCmd
  606.  
  607.   "
  608.  
  609.   set SqlOut [RunSqlplus ${PwdConnectString} $SqlCmd]
  610.  
  611.   set err_rep [OraErrorReport $SqlOut ""]
  612.  
  613.   if {$err_rep != ""} {
  614.      set ErrMsg "\nError during running sqlplus:"
  615.      set LogMsg "${ErrMsg}\n\n${err_rep}\n${SqlOut}\n"
  616.      set StatString "Status \"SCHEMAERROR\"\n"
  617.      error $LogMsg $StatString "STOP"
  618.   }
  619.   set SizeString "Size ${SqlOut}\n"
  620.  
  621.   # DO NOT remove dumbVar setting. It will change script behavior!!!
  622.   set dumbVar ""
  623.  
  624. } MainError
  625.  
  626. if {$errorCode == "STOP" || $errorCode == "" || $errorCode == "NONE"} {
  627.     WriteLog $StatString
  628.     WriteLog $SizeString
  629.     WriteLog $LogMsg
  630.     exit 0
  631. }
  632.  
  633. WriteLog "Status \"UNKNOWN\"\n"
  634. WriteLog "Size 0\n"
  635. WriteLog "TCL error code: ${errorCode}\n"
  636. WriteLog "TCL error info: ${errorInfo}\n"
  637. WriteLog $LogMsg
  638.  
  639. exit 1
  640.  
  641.