PowerDesigner中遍历物理模型中的所有表,检查表代码、字段代码
'******************************************************************************
'* File: comment2name.vbs
'* Author: Jason Chen
'* Created: 2014
'* Modified: 2017/6
'* Version: 2.0
'* Comment: 把表中的描述信息复制为Name,增强可读性
'* Used: 打开物理模型,运行本脚本(Ctrl+Shift+X)
'* Comment:
'****************************************************************************** Option Explicit
ValidationMode = True
InteractiveMode = im_Batch Dim mdl 'the current model '获取当前活动的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
for each Tab in folder.tables
if not tab.isShortcut then
tab.name = tab.code & " " & getName(tab.comment)
Dim col ' running column
for each col in tab.columns
if col.comment="" then
else
col.name = getName(col.comment)
end if
next
end if
next '遍历视图
Dim view
for each view in folder.Views
if not view.isShortcut then
view.name = getName(view.comment)
end if
next '遍历包
Dim f 'running folder
For Each f In folder.Packages
if not f.IsShortcut then
ProcessFolder f
end if
Next
end sub '获取名称
Function getName(colComment)
dim index
dim indexArray(10) '排除掉"X"后的文本
indexArray(0) = InStr(colComment, ":")
indexArray(1) = InStr(colComment, vbcrlf)
indexArray(2) = InStr(colComment, ":")
indexArray(3) = InStr(colComment, "(")
indexArray(4) = InStr(colComment, "【")
indexArray(5) = InStr(colComment, "[")
indexArray(6) = InStr(colComment, "(")
indexArray(7) = InStr(colComment, ",")
indexArray(8) = InStr(colComment, " ")
indexArray(9) = InStr(colComment, ":")
index = getArrMinValueIndex(indexArray) if index > 0 then
Output index
getName = Mid(colComment, 1, index-1)
else getName = colComment
end if
end Function '查找最近一个匹配字符的位置
Function getArrMinValueIndex(ByVal arr)
Dim ix, itemMin
itemMin = 0
For ix = 1 To UBound(arr)
If arr(ix) > 0 and (itemMin = 0 or itemMin > arr(ix)) Then
itemMin = arr(ix)
End If
Next
getArrMinValueIndex = itemMin
End Function
PowerDesigner中遍历物理模型中的所有表,检查表代码、字段代码的更多相关文章
- 【转载】C#中遍历DataTable中的数据行
在C#中的Datatable数据变量的操作过程中,有时候我们需要遍历DataTable变量获取每一行的数据值,例如将DataTable变量转换为List集合的时候,我们就会遍历DataTable变量, ...
- Oracle中使用游标获取指定数据表的所有字段名对应的字符串
操作步骤:打开PLSQL Developer后,直接执行下面的语句就可以出来 --Oracle中使用游标获取指定数据表的所有字段名对应的字符串 declare mytablename VARCHAR( ...
- oracle中查询表的信息,包括表名,字段名,字段类型,主键,外键唯一性约束信息
来源于网上整理 总结了一下oracle中查询表的信息,包括表名,字段名,字段类型,主键,外键唯一性约束信息,索引信息查询SQL如下,希望对大家有所帮助: 1.查询出所有的用户表select * fro ...
- SqlServer中获取所有数据库,所有表,所有字段
原文:SqlServer中获取所有数据库,所有表,所有字段 一.获取所有数据库 select * from master.dbo.SysDatabases 二.获取某个库中所有表 SELECT * F ...
- MySQL 中的数据库名称、数据表名称、字段名称
如何查询Oracle,Sql Server,MySQL 中的数据库名称.数据表名称.字段名称 分类: Database2012-09-24 22:16 7034人阅读 评论(0) 收藏 举报 数据库s ...
- 关于C#中遍历字符串中的每个字符的方法
解决方案 C#提供了两个方法用于遍历字符串. 1.第一个方法是foreach循环,这个方法快速且容易,但是与第二个方法相比它不太灵活.其使用方法如下: string testStr = "a ...
- Python 中遍历序列中元素和下标
enumerate 函数用于遍历序列中的元素以及它们的下标 for i,v in enumerate(['tic','tac','toe']): print i,v #0 tic #1 tac #2 ...
- 查找sqlserver数据库中,查询某值所表名和字段名
有时候我们想通过一个值知道这个值来自数据库的哪个表以及哪个字段,通过一个存储过程实现的.只需要传入一个想要查找的值,即可查询出这个值所在的表和字段名. 前提是要将这个存储过程放在所查询的数据库. CR ...
- ADF中遍历VO中的行数据(Iterator)
在ADF中VO实质上就是一个迭代器, 1.在Application Module的实现类中,直接借助VO实现类和Row的实现类 TestVOImpl organizationUser = (TestV ...
随机推荐
- SQL Server 数据库文件管理
关于数据库文件的管理问题,我经常说,常在江湖混,哪有不挨棍,用的时间长了,基本上都有遇到一些数据库文件管理上的问题,比如说: 1. SQL Server数据文件空间满 2. 日志文件暴涨 3. 文件不 ...
- Japan
Japan plans to welcome the ACM ICPC World Finals and a lot of roads must be built for the venue. Jap ...
- DIH
DIH内存溢出: 在使用DIH时,容易报内存溢出错误.可以通过设置jvm大小来解决.设置方法如下: 在tomcat\bin\startup.bat 加入SET JAVA_OPTS=-Xms128m - ...
- java 输入输出 函数对象构造
/*********************输入输出*******************/ //输入字符串 不包括最后的换行符'\n' import java.io.BufferedRe ...
- [Java] Serializable(序列化)的理解
1.序列化是干什么的? 简单说就是为了保存在内存中的各种对象的状态(也就是实例变量,不是方法),并且可以把保存的对象状态再读出来.虽然你可以用你自己的各种各样的方法来保存object st ...
- NODE编程(四)--构建Node Web程序2
四.提供静态文件服务 1.创建一个静态文件服务器 __dirname ,取值是该文件所在咋目录路径.分散在不同目录中的文件可以有不同的值. /** * 最进本的ReadStream静态文件服务器 */ ...
- 【阿里云产品公测】与云引擎ACE第一次亲密接触
阿里云用户:林哥神话 公测当然是第一次了.这个第一次亲密接触,但话又说回来对ACE我一直都不是那感兴趣的,但是看到阿里介绍还是那般神奇,再加上200无代金券来更加给力.最后就申请了这次公测. 平时一直 ...
- struts1.3设置编码三种方法
本文所写涉及的struts的版本是1.3x. 一.改写struts的ActionServlet. 重写process()方法: 配置相应的web.xml文件 三.通过Chain来处理: 使用cha ...
- CSS3实战手册(第3版)(影印版)
<CSS3实战手册(第3版)(影印版)> 基本信息 原书名:CSS3: The Missing Manual, 3E 作者: David Sawyer McFarland 出版社:东南大学 ...
- seajs第二节,seajs各模块依赖关系
index.html <!DOCTYPE html> <html> <head> <meta charset="utf-8"> &l ...