PowerDesigner設計Name和Comment 替換

這兩天在用powerdesigner設計數據庫。一直以爲name就是註釋名字來着。後來生成sql語句 怎麼就沒有註釋信息那。 後來看了半天才知道自己範2了。

通過各種信息查找。大多都是改database下的edit current DBMS 裏面的東西。但是這樣生成出來 不能直接執行。 自己琢磨半天。又查了查資料終於找到了。

comment 是註釋。name 是字段描述

在 PowerDesigner中操作如下

PowerDesigner-->Tools-->Execute  Commands-->Edit/Run Scripts  下執行就OK了。

執行代碼--------------------------------

把comment 覆蓋name  方法如下:

Option   Explicit

ValidationMode   =   True 

InteractiveMode   =   im_Batch

Dim   mdl   '   the   current   model

'   get   the   current   active   model

Set   mdl   =   ActiveModel 

If   (mdl   Is   Nothing)   Then 

MsgBox   "There   is   no   current   Model " 

ElseIf   Not   mdl.IsKindOf(PdPDM.cls_Model)   Then 

MsgBox   "The   current   model   is   not   an   Physical   Data   model. " 

Else 

ProcessFolder   mdl 

End   If

Private   sub   ProcessFolder(folder)

On Error Resume Next

Dim   Tab   'running     table 

for   each   Tab   in   folder.tables 

if   not   tab.isShortcut   then 

tab.name   =   tab.comment

Dim   col   '   running   column 

for   each   col   in   tab.columns 

if col.comment="" then

else

col.name=   col.comment 

end if

next 

end   if 

next

Dim   view   'running   view

for   each   view   in   folder.Views 

if   not   view.isShortcut   then 

view.name   =   view.comment 

end   if 

next

'   go   into   the   sub-packages

Dim   f   '   running   folder 

For   Each   f   In   folder.Packages 

if   not   f.IsShortcut   then 

ProcessFolder   f 

end   if 

Next 

end   sub

將name覆蓋 comment  方法如下

Option   Explicit

ValidationMode   =   True 

InteractiveMode   =   im_Batch

Dim   mdl   '   the   current   model

'   get   the   current   active   model

Set   mdl   =   ActiveModel 

If   (mdl   Is   Nothing)   Then 

MsgBox   "There   is   no   current   Model " 

ElseIf   Not   mdl.IsKindOf(PdPDM.cls_Model)   Then 

MsgBox   "The   current   model   is   not   an   Physical   Data   model. " 

Else 

ProcessFolder   mdl 

End   If

'   This   routine   copy   name   into   comment   for   each   table,   each   column   and   each   view

'   of   the   current   folder 

Private   sub   ProcessFolder(folder) 

Dim   Tab   'running     table 

for   each   Tab   in   folder.tables 

if   not   tab.isShortcut   then 

tab.comment   =   tab.name 

Dim   col   '   running   column 

for   each   col   in   tab.columns 

col.comment=   col.name 

next 

end   if 

next

Dim   view   'running   view

for   each   view   in   folder.Views 

if   not   view.isShortcut   then 

view.comment   =   view.name 

end   if 

next

'   go   into   the   sub-packages

Dim   f   '   running   folder 

For   Each   f   In   folder.Packages 

if   not   f.IsShortcut   then 

ProcessFolder   f 

end   if 

Next 

end   sub

完事。 自己糾結了好久。 終於解決了  自己留個紀念。順便給菜鳥們存個檔

將comment覆蓋name

原文  http://www.cnblogs.com/LMJBlogs/p/4544366.html

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章