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 ...
随机推荐
- 关于Android使TextView可以滚动的设置
添加一行代码…… textView.setMovementMethod(ScrollingMovementMethod.getInstance());
- solr 高亮配置
solrj中配置: 两种高亮开启设置 // solrParams.setHighlight(true); solrParams.setParam("hl", "true& ...
- ListView的addAll方法
add是将传入的参数作为当前List中的一个Item存储,即使你传入一个List也只会另当前的List增加1个元素addAll是传入一个List,将此List中的所有元素加入到当前List中,也就是当 ...
- IOS 应用中从竖屏模式强制转换为横屏模式
在 iPhone 应用里,有时我们想强行把显示模式从纵屏改为横屏(反之亦然),CocoaChina 会员 “alienblue” 为我们提供了两种思路 第一种:通过人为的办法改变view.transf ...
- 5. Android框架和工具之 ZXing(二维码)
Android进阶笔记06:Android 实现扫描二维码实现网页登录
- ubuntu16.04 编译安装mysql5.7.x,以及配置使用
編譯與安裝: 源码下载地址:http://dev.mysql.com/downloads/mysql/ 选择Generic Linux (Architecture Independent), C ...
- 错误"Lc.exe 已退出,代码 -1 "
今天做项目的时候突然出现编译不通过,错误为Lc.exe已退出,代码为-1.这让我郁闷了至少30分钟,后来上网查了一下,才知道原因所在,我们项目中使用了第三方组件(Infragistics)造成的,至于 ...
- LearnMVC5-AddController
原创文章,转载必需注明出处:http://www.ncloud.hk/%E6%8A%80%E6%9C%AF%E5%88%86%E4%BA%AB/learnmvc5-addcontroller/ 本人是 ...
- php 笔试面试 总结
一次小小的笔试面试经历,虽然是一些简单的问题,但是自己在这儿总结一下,也查一些资料,得出一些较好的答案,也能帮助自己成长. 1.自己熟悉的http状态码及其意义 其实这个题答案随处可见.这儿也还是记录 ...
- 日期类型的input元素设置默认值为当天
html文件:<input name="" type="date" value="" id="datePicker" ...