首页 > 代码库 > PowerDesigner中在生成的数据库脚本中用name列替换comment列作为字段描述的方法

PowerDesigner中在生成的数据库脚本中用name列替换comment列作为字段描述的方法

1 PowerDesigner中在生成的数据库脚本中用name列替换comment列作为字段描述的方法如下,

依次打开Tools -- Execute Commands -- Run Script,运行以下脚本:

Option ExplicitValidationMode = TrueInteractiveMode = im_BatchDim mdl the current modelget 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 IfThis routine copy name into code for each table, each column and each viewof the current folderPrivate sub ProcessFolder(folder)Dim Tab running tablefor each Tab in folder.tablesif not tab.isShortcut thentab.comment = tab.nameDim col running columnfor each col in tab.columnscol.comment= col.namenextend ifnextDim view running viewfor each view in folder.Viewsif not view.isShortcut thenview.comment = view.nameend ifnextgo into the sub-packagesDim f running folderFor Each f In folder.Packagesif not f.IsShortcut thenProcessFolder fend ifNextend sub

 



2 PowerDesigner的数据库逆向工程将中将comment列脚本赋值到name列


打开Tools -- Execute Commands -- Run Script,运行以下脚本:

Option ExplicitValidationMode = TrueInteractiveMode = im_BatchDim mdl the current modelget 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 IfThis routine copy name into code for each table, each column and each viewof the current folderPrivate sub ProcessFolder(folder)Dim Tab running tablefor each Tab in folder.tablesif not tab.isShortcut thenif len(tab.comment) <> 0 thentab.name = tab.commentend ifOn Error Resume NextDim col running columnfor each col in tab.columnsif len(col.comment) <>0 thencol.name =col.commentend ifOn Error Resume Nextnextend ifnextend sub