转-PowerDesigner 把Comment复制到name中和把name复制到Comment

在使用PowerDesigner对数据库进行概念模型和物理模型设计时,一般在NAME或Comment中写中文,在Code中写英文。Name用来显 示,Code在代码中使用,但Comment中的文字会保存到数据库Table或Column的Comment中,当Name已经存在的时候,再写一次 Comment很麻烦,可以使用以下代码来解决这个问题

在PowerDesigner中使用方法为:

PowerDesigner->Tools->Execute Commands->Edit/Run Scripts

将代码Copy进去执行就可以了,是对整个CDM或PDM进行操作

  1. Option   Explicit
  2. ValidationMode   =   True
  3. InteractiveMode   =   im_Batch
  4. Dim   mdl   '   the   current   model
  5. '   get   the   current   active   model
  6. Set   mdl   =   ActiveModel
  7. If   (mdl   Is   Nothing)   Then
  8. MsgBox   "There   is   no   current   Model "
  9. ElseIf   Not   mdl.IsKindOf(PdPDM.cls_Model)   Then
  10. MsgBox   "The   current   model   is   not   an   Physical   Data   model. "
  11. Else
  12. ProcessFolder   mdl
  13. End   If
  14. '   This   routine   copy   name   into   comment   for   each   table,   each   column   and   each   view
  15. '   of   the   current   folder
  16. Private   sub   ProcessFolder(folder)
  17. Dim   Tab   'running     table
  18. for   each   Tab   in   folder.tables
  19. if   not   tab.isShortcut   then
  20. tab.comment   =   tab.name
  21. Dim   col   '   running   column
  22. for   each   col   in   tab.columns
  23. col.comment=   col.name
  24. next
  25. end   if
  26. next
  27. Dim   view   'running   view
  28. for   each   view   in   folder.Views
  29. if   not   view.isShortcut   then
  30. view.comment   =   view.name
  31. end   if
  32. next
  33. '   go   into   the   sub-packages
  34. Dim   f   '   running   folder
  35. For   Each   f   In   folder.Packages
  36. if   not   f.IsShortcut   then
  37. ProcessFolder   f
  38. end   if
  39. Next
  40. end   sub

另外在使用REVERSE ENGINEER从数据库反向生成PDM的时候,PDM中的表的NAME和CODE事实上都是CODE,为了把NAME替换为数据库中Table或Column的中文Comment,可以使用以下脚本:

    1. '代码二:将Comment中的字符COPY至Name中
    2. Option   Explicit
    3. ValidationMode   =   True
    4. InteractiveMode   =   im_Batch
    5. Dim   mdl   '   the   current   model
    6. '   get   the   current   active   model
    7. Set   mdl   =   ActiveModel
    8. If   (mdl   Is   Nothing)   Then
    9. MsgBox   "There   is   no   current   Model "
    10. ElseIf   Not   mdl.IsKindOf(PdPDM.cls_Model)   Then
    11. MsgBox   "The   current   model   is   not   an   Physical   Data   model. "
    12. Else
    13. ProcessFolder   mdl
    14. End   If
    15. Private   sub   ProcessFolder(folder)
    16. On Error Resume Next
    17. Dim   Tab   'running     table
    18. for   each   Tab   in   folder.tables
    19. if   not   tab.isShortcut   then
    20. tab.name   =   tab.comment
    21. Dim   col   '   running   column
    22. for   each   col   in   tab.columns
    23. if col.comment="" then
    24. else
    25. col.name=   col.comment
    26. end if
    27. next
    28. end   if
    29. next
    30. Dim   view   'running   view
    31. for   each   view   in   folder.Views
    32. if   not   view.isShortcut   then
    33. view.name   =   view.comment
    34. end   if
    35. next
    36. '   go   into   the   sub-packages
    37. Dim   f   '   running   folder
    38. For   Each   f   In   folder.Packages
    39. if   not   f.IsShortcut   then
    40. ProcessFolder   f
    41. end   if
    42. Next
    43. end   sub
    44. 原帖地址:http://blog.csdn.net/smartsmile2012/article/details/7922863

power desinger 学习笔记<八>的更多相关文章

  1. power desinger 学习笔记<四>

    Tools <display preferences> <content table> <advanced> Columns 选择放大镜图标 进入窗口 选择要顺序显 ...

  2. power desinger 学习笔记三<批量执行sql语句>

    使用sql脚本导入表结构,直接 附带表的 约束.列的注释.真的可以哦 sql语句如下: create table test01 (   ID                   VARCHAR2(10 ...

  3. power desinger 学习笔记<二>

    power designer 设计表时显示注释选项 PowerDesigner设计时表显示注释选项: 选定编辑的表,右键- > Properties- > Columns- > Cu ...

  4. power desinger 学习笔记<一>

    如果一张表有 很多字段(多于30个),那么一个一个复制粘贴,耗时耗力.可以偷懒,事先编辑好 sql脚本,然后把sql脚本导入 power designer,是不是很方便?  看下面的 1. 打开Pow ...

  5. power desinger 学习笔记<六>

    原帖地址:http://blog.csdn.net/spt110/article/details/8640849 PowerDesigner中Table视图同时显示Code和Name,像下图这样的效果 ...

  6. power desinger 学习笔记<五>

    怎样才能在修改表的字段Name的时候,Code不自动跟着变 tools-> General   Options-> Dialog:Operation   Modes: 去掉 NameToC ...

  7. C#可扩展编程之MEF学习笔记(四):见证奇迹的时刻

    前面三篇讲了MEF的基础和基本到导入导出方法,下面就是见证MEF真正魅力所在的时刻.如果没有看过前面的文章,请到我的博客首页查看. 前面我们都是在一个项目中写了一个类来测试的,但实际开发中,我们往往要 ...

  8. IOS学习笔记(四)之UITextField和UITextView控件学习

    IOS学习笔记(四)之UITextField和UITextView控件学习(博客地址:http://blog.csdn.net/developer_jiangqq) Author:hmjiangqq ...

  9. java之jvm学习笔记四(安全管理器)

    java之jvm学习笔记四(安全管理器) 前面已经简述了java的安全模型的两个组成部分(类装载器,class文件校验器),接下来学习的是java安全模型的另外一个重要组成部分安全管理器. 安全管理器 ...

随机推荐

  1. 在eclipse中安装activiti插件

    最近在学习activiti,先学习安装插件吧. 单击help->Install new Software 然后添加资源 name:activiti location:http://activit ...

  2. (转载)不能启动虚拟机 Unable to open kernel device "\\.\Global\vmx86

    (转载)http://blog.csdn.net/shenghuiping2001/article/details/7083153 今天系统加了内存条,设置变了一下: 就启动不起虚拟机了,报错: Un ...

  3. PHP_SELF、 SCRIPT_NAME、 REQUEST_URI 区别

    $_SERVER[PHP_SELF], $_SERVER[SCRIPT_NAME], $_SERVER['REQUEST_URI'] 在用法上是非常相似的,他们返回的都是与当前正在使用的页面地址有关的 ...

  4. Unity之Avatar原理

    今天花了一些时间理了理Unity的动画系统. 之前给不同模型配动画时没怎么在意,只知道用Avatar可以让一个模型使用另一个模型的动画.由于用的基本上都是人物模型,基本上没出现什么错误. 不过在用到异 ...

  5. 常见sql的error解决方法

    1.sqlserver 2008 login failed: error 18456 这是很可能是因为你没有选择sql and windows登录的模式导致sql server的用户登录失败 解决方法 ...

  6. Bzoj 2588: Spoj 10628. Count on a tree 主席树,离散化,可持久,倍增LCA

    题目:http://www.lydsy.com/JudgeOnline/problem.php?id=2588 2588: Spoj 10628. Count on a tree Time Limit ...

  7. Java编程-基本语句

    一个基本的输出语句: package Hello; import java.util.Scanner; public class Hello { public static void main(Str ...

  8. 代码编写横屏的UIView

    - (id )initWithFrame:(CGRect )frame { if (self = [super initWithFrame :frame]) { // Important here, ...

  9. Wall - POJ 1113(求凸包)

    题目大意:给N个点,然后要修建一个围墙把所有的点都包裹起来,但是要求围墙距离所有的点的最小距离是L,求出来围墙的长度. 分析:如果没有最小距离这个条件那么很容易看出来是一个凸包,然后在加上一个最小距离 ...

  10. Oracle索引(B*tree与Bitmap)的学习总结

    在Oracle中,索引基本分为以下几种:B*Tree索引,反向索引,降序索引,位图索引,函数索引,interMedia全文索引等,其中最常用的是B*Tree索引和Bitmap索引.(1).与索引相关视 ...