'****************************************************************************** '* File: name2comment.vbs '* Purpose: Database generation cannot use object names anymore ' in version 7 and above. ' It always uses the object codes. ' ' In case the object codes are not aligned with your ' object names in your model, this script will copy ' the object Name onto the object Comment for ' the Tables and Columns. ' '* Title: '* Version: 1.0 '* Company: Sybase Inc. '****************************************************************************** OptionExplicit ValidationMode =True InteractiveMode = im_Batch Dim mdl ' the current model ' get the current active model Set mdl = ActiveModel If (mdl IsNothing) Then MsgBox"There is no current Model " ElseIfNot mdl.IsKindOf(PdPDM.cls_Model) Then MsgBox"The current model is not an Physical Data model. " Else ProcessFolder mdl EndIf ' This routine copy name into comment for each table, each column and each view ' of the current folder Privatesub ProcessFolder(folder) Dim Tab 'running table foreach Tab in folder.tables ifnot tab.isShortcut then tab.comment = tab.name Dim col ' running column foreach col in tab.columns col.comment= col.name next endif next Dim view 'running view foreach view in folder.Views ifnot view.isShortcut then view.comment = view.name endif next ' go into the sub-packages Dim f ' running folder ForEach f In folder.Packages ifnot f.IsShortcut then ProcessFolder f endif Next endsub
代码二:将Comment中的字符COPY至Name中
OptionExplicit ValidationMode =True InteractiveMode = im_Batch Dim mdl ' the current model ' get the current active model Set mdl = ActiveModel If (mdl IsNothing) Then MsgBox"There is no current Model " ElseIfNot mdl.IsKindOf(PdPDM.cls_Model) Then MsgBox"The current model is not an Physical Data model. " Else ProcessFolder mdl EndIf Privatesub ProcessFolder(folder) OnErrorResumeNext Dim Tab 'running table foreach Tab in folder.tables ifnot tab.isShortcut then tab.name = tab.comment Dim col ' running column foreach col in tab.columns if col.comment=""then else col.name= col.comment endif next endif next Dim view 'running view foreach view in folder.Views ifnot view.isShortcut then view.name = view.comment endif next ' go into the sub-packages Dim f ' running folder ForEach f In folder.Packages ifnot f.IsShortcut then ProcessFolder f endif Next endsub