使用Reverse engineer从数据库反向生成PDM的时候,PDM中的表的Name和Code事实上都是Code,为了把Name替换为数据库中Table或Column的中文Comment,可以使用以下脚本:在PowerDesigner中使用方法为:
PowerDesigner->Tools->Execute Commands->Edit/Run Scripts
或 工具->Execute Commands->Edit/Run Scripts
将代码Copy进去执行就可以了,是对整个CDM或PDM进行操作
修改前
修改后
Option ExplicitValidationMode = TrueInteractiveMode = im_BatchDim mdl ' the current model' get the current active modelSet mdl = ActiveModelIf (mdl Is Nothing) ThenMsgBox "There is no current Model "ElseIf Not mdl.IsKindOf(PdPDM.cls_Model) ThenMsgBox "The current model is not an Physical Data model. "ElseProcessFolder mdlEnd IfPrivate sub ProcessFolder(folder)On Error Resume NextDim Tab 'running tablefor each Tab in folder.tablesif not tab.isShortcut thentab.name = tab.commentDim col ' running columnfor each col in tab.columnsif col.comment="" thenelsecol.name= col.commentend ifnextend ifnextDim view 'running viewfor each view in folder.Viewsif not view.isShortcut thenview.name = view.commentend ifnext' go into the sub-packagesDim f ' running folderFor Each f In folder.Packagesif not f.IsShortcut thenProcessFolder fend ifNextend sub