PowerDesigner列名、注释内容互换

在用PowerDesigner时,常常在NAME或Comment中写中文在Code中写英文,Name只会显示给我们看,Code会使用在代码中,但Comment中的文字会保存到数据库TABLE的Description中,有时候我们写好了Name再写一次Comment很麻烦,以下两段代码就可以解决这个问题。
在PowerDesigner中PowerDesigner->Tools->Execute Commands->Edit/Run Scripts(Ctrl Shift X),然后将下面的脚本粘贴进去,并运行,即可

1代码一:将Name中的字符COPY至Comment中 2'****************************************************************************** 3'* File: name2comment.vbs 4'* Purpose: Database generation cannot use object names anymore 5' in version 7 and above. 6' It always uses the object codes. 7' 8' In case the object codes are not aligned with your 9' object names in your model, this script will copy 10' the object Name onto the object Comment for 11' the Tables and Columns. 12' 13'* Title: 14'* Version: 1.0 15'* Company: Sybase Inc. 16'****************************************************************************** 17Option Explicit 18ValidationMode = True 19InteractiveMode = im_Batch 20 21Dim mdl ' the current model 22 23' get the current active model 24Set mdl = ActiveModel 25If (mdl Is Nothing) Then 26 MsgBox "There is no current Model " 27ElseIf Not mdl.IsKindOf(PdPDM.cls_Model) Then 28 MsgBox "The current model is not an Physical Data model. " 29Else 30 ProcessFolder mdl 31End If 32 33' This routine copy name into comment for each table, each column and each view 34' of the current folder 35Private sub ProcessFolder(folder) 36 Dim Tab 'running table 37 for each Tab in folder.tables 38 if not tab.isShortcut then 39 tab.comment = tab.name 40 Dim col ' running column 41 for each col in tab.columns 42 col.comment= col.name 43 next 44 end if 45 next 46 47 Dim view 'running view 48 for each view in folder.Views 49 if not view.isShortcut then 50 view.comment = view.name 51 end if 52 next 53 54 ' go into the sub-packages 55 Dim f ' running folder 56 For Each f In folder.Packages 57 if not f.IsShortcut then 58 ProcessFolder f 59 end if 60 Next 61end sub 62 63代码二:将Comment中的字符COPY至Name中 64Option Explicit 65ValidationMode = True 66InteractiveMode = im_Batch 67 68Dim mdl ' the current model 69 70' get the current active model 71Set mdl = ActiveModel 72If (mdl Is Nothing) Then 73 MsgBox "There is no current Model " 74ElseIf Not mdl.IsKindOf(PdPDM.cls_Model) Then 75 MsgBox "The current model is not an Physical Data model. " 76Else 77 ProcessFolder mdl 78End If 79 80Private sub ProcessFolder(folder) 81On Error Resume Next 82 Dim Tab 'running table 83 for each Tab in folder.tables 84 if not tab.isShortcut then 85 tab.name = tab.comment 86 Dim col ' running column 87 for each col in tab.columns 88 if col.comment="" then 89 else 90 col.name= col.comment 91 end if 92 next 93 end if 94 next 95 96 Dim view 'running view 97 for each view in folder.Views 98 if not view.isShortcut then 99 view.name = view.comment 100 end if 101 next 102 103 ' go into the sub-packages 104 Dim f ' running folder 105 For Each f In folder.Packages 106 if not f.IsShortcut then 107 ProcessFolder f 108 end if 109 Next 110end sub 111 112代码三:将Name中的字符COPY至Comment中(优化) 113'把pd中那么name想自动添加到comment里面 114'如果comment为空,则填入name;如果不为空,则保留不变,这样可以避免已有的注释丢失. 115 116Option Explicit 117ValidationMode = True 118InteractiveMode = im_Batch 119 120Dim mdl ' the current model 121 122' get the current active model 123Set mdl = ActiveModel 124If (mdl Is Nothing) Then 125 MsgBox "There is no current Model " 126ElseIf Not mdl.IsKindOf(PdPDM.cls_Model) Then 127 MsgBox "The current model is not an Physical Data model. " 128Else 129 ProcessFolder mdl 130End If 131 132' This routine copy name into comment for each table, each column and each view 133' of the current folder 134Private sub ProcessFolder(folder) 135 Dim Tab 'running table 136 for each Tab in folder.tables 137 if not tab.isShortcut then 138 if trim(tab.comment)="" then '如果有表的注释,则不改变它.如果没有表注释.则把name添加到注释里面. 139 tab.comment = tab.name 140 end if 141 Dim col ' running column 142 for each col in tab.columns 143 if trim(col.comment)="" then '如果col的comment为空,则填入name,如果已有注释,则不添加;这样可以避免已有注释丢失. 144 col.comment= col.name 145 end if 146 next 147 end if 148 next 149 150 Dim view 'running view 151 for each view in folder.Views 152 if not view.isShortcut and trim(view.comment)="" then 153 view.comment = view.name 154 end if 155 next 156 157 ' go into the sub-packages 158 Dim f ' running folder 159 For Each f In folder.Packages 160 if not f.IsShortcut then 161 ProcessFolder f 162 end if 163 Next 164end sub
点赞
收藏

评论区

加载中...

相关推荐

MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1

文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s

Oracle 分组与拼接字符串同时使用

SELECTT.,ROWNUMIDFROM(SELECTT.EMPLID,T.NAME,T.BU,T.REALDEPART,T.FORMATDATE,SUM(T.S0)S0,MAX(UPDATETIME)CREATETIME,LISTAGG(TOCHAR(

MySQL部分从库上面因为大量的临时表tmp_table造成慢查询

背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_

皕杰报表之UUID

​在我们用皕杰报表工具设计填报报表时,如何在新增行里自动增加id呢?能新增整数排序id吗?目前可以在新增行里自动增加id,但只能用uuid函数增加UUID编码,不能新增整数排序id。uuid函数说明:获取一个UUID,可以在填报表中用来创建数据ID语法:uuid()或uuid(sep)参数说明:sep布尔值,生成的uuid中是否包含分隔符'',缺省为

java将前端的json数组字符串转换为列表

记录下在前端通过ajax提交了一个json数组的字符串,在后端如何转换为列表。前端数据转化与请求varcontracts{id:'1',name:'yanggb合同1'},{id:'2',name:'yanggb合同2'},{id:'3',name:'yang

2020年前端实用代码段,为你的工作保驾护航

有空的时候,自己总结了几个代码段,在开发中也经常使用,谢谢。1、使用解构获取json数据let jsonData  id: 1,status: "OK",data: 'a', 'b';let  id, status, data: number   jsonData;console.log(id, status, number )

PowerDesigner列名、注释内容互换 - HelloWorld