/** * PowerDesigner裡面將表中name列值複製到comment列 * @see -----------------------------------------------------------------------------------------------------... ...
- /**
- * PowerDesigner裡面將表中name列值複製到comment列
- * @see --------------------------------------------------------------------------------------------------------------------
- * @see pd中的pdm預設生成sql時,欄位是沒有註釋的..想要註釋的話,有2個方法
- * @see 1.也是推薦的
- * @see pdm中雙擊打開一個Table,到Columns選項卡中,按快捷鍵Ctrl+U,找到Comment並勾選即可
- * @see 而且該操作設置一次就行了,以後在新的Table中也會自動出現Comment
- * @see 設置完畢後,在添加表欄位時一併寫上註釋,這樣生成的sql中欄位就會有註釋了
- * @see 2.執行vbs腳本
- * @see 相較第一種方法,該方法缺點是每次生成sql前,都要執行一遍這個腳本
- * @see 執行方式為Tools-->Execute Commands-->Edit/Run Scripts,或者直接快捷鍵Ctrl+Shift+X
- * @see 將下麵的腳本拷進去執行一遍,也可以保存為name2comment.vbs(下一次再執行的話,就可以Ctrl+O再選擇name2comment.vbs即可)
- * @see --------------------------------------------------------------------------------------------------------------------
- */
' 如果comment為空,則填入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 if trim(tab.comment)="" then '如果有表的註釋,則不改變它;如果沒有表註釋,則把name添加到註釋中. tab.comment = tab.name end if Dim col ' running column for each col in tab.columns if trim(col.comment)="" then '如果col的comment為空,則填入name;如果已有註釋,則不添加.這樣可以避免已有註釋丟失. col.comment= col.name end if next end if next Dim view 'running view for each view in folder.Views if not view.isShortcut and trim(view.comment)="" 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