PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码
Posted on 2012-04-04 21:12 wanderer 阅读(200) 评论(0) 收藏 举报在用PowerDesigner时.常常在NAME或Comment中写中文在Code中写英文.Name只会显示给我们看,Code会使用在代码中.但Comment中的文字会保存到数据库TABLE的Description中,有时候我们写好了Name再写一次Comment很麻烦.以下两段代码就可以解决这个问题.
在PowerDesigner中按Ctrl + Shift + X,然后将下面的脚本粘贴进去,并运行,就可以
代码一:将Name中的字符COPY至Comment中

'******************************************************************************
'* 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
浙公网安备 33010602011771号