在用PowerDesigner时.常常在NAME或Comment中写中文在Code中写英文.Name只会显示给我们看,Code会使用在代码中.但Comment中的文字会保存到数据库TABLE的Description中,有时候我们写好了Name再写一次Comment很麻烦.以下两段代码就可以解决这个问题.

使用菜单:"Tools->Execute Commands->Edit/Run Scripts"来执行下面脚本

 代码一:将Name中的字符COPY至Comment中


'****************************************************************************** 
'*   File:           name2comment.vbs 
'*   Purpose:     Database   generation   cannot   use   object   names   anymore   
'                         in   version   7   and   above. 
'                         It   always   uses   the   object   codes. 

'                         In   case   the   object   codes   are   not   aligned   with   your   
'                         object   names   in   your   model,   this   script   will   copy   
'                         the   object   Name   onto   the   object   Comment   for   
'                         the   Tables   and   Columns. 

'*   Title:         
'*   Version:     1.0 
'*   Company:     Sybase   Inc.   
'****************************************************************************** 


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中的字符COPY至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

最新文章

  1. 【跟着子迟品 underscore】for ... in 存在的浏览器兼容问题你造吗
  2. 20145213《Java程序设计》实验五Java网络编程及安全
  3. [译] Angular 2 VS. React: 血色将至
  4. JS和JQUERY的区别
  5. struts2——通配符
  6. 数据导出为excel表格
  7. linux下gitflow辅助工具安装和使用
  8. C#判断用户是否使用微信浏览器,并据此来显示真实内容或二维码
  9. MySQL导入数据非常慢的解决办法
  10. 熟人Dubbo 系列1-Dubbo什么
  11. 带您了解mysql CONCAT()函数
  12. 借鉴别人的Oracle 11g安装和卸载图文教程
  13. MySQL安装目录修改
  14. fastcgi协议之一:定义
  15. c++ 指针访问数组
  16. Android平台下OpenGL图形编程
  17. BZOJ-3509 母函数+分块+暴力+FFT
  18. Java中常用的日期操作方法
  19. Maven的使用入门
  20. python3条件表达式和字符串

热门文章

  1. python字典形list 去重复
  2. 【css】cursor鼠标指针光标样式知识整理
  3. java util - 中文、繁体转成拼音工具pinyin4j
  4. 04.VUE学习之v-text v-html
  5. Java总结 - List实现类ArrayList&LinkedList
  6. __setitem__,__getitem,__delitem__的作用
  7. North American Invitational Programming Contest (NAIPC) 2017
  8. Appium环境搭建及“fn must be a function”问题解决
  9. P1198 [JSOI2008]最大数(单调栈)
  10. 通过js date对象获取各种开始结束日期的示例