PowerDesigner中遍历物理模型中的所有表,检查表代码、字段代码

‘*****************************************************************************
‘文件:CheckCode4SqlServer.vbs
‘版本:1.0
‘功能:遍历物理模型中的所有表,检查表代码、字段代码
‘      是否包含空格、是否包含中文、是否为系统关键字、是否长度超过116
‘用法:打开物理模型,运行本脚本(Ctrl+Shift+X)
‘备注:
‘*****************************************************************************
 dim model ‘current model
 set model = ActiveModel
 If (model Is Nothing) Then
   MsgBox "没有选择模型,请选择一个模型并打开."
 ElseIf Not model.IsKindOf(PdPDM.cls_Model) Then
   MsgBox "当前选择的不是一个物理模型(PDM)."
 Else
   ProcessTables model
 End If

‘*****************************************************************************
‘过程:ProcessTables
‘功能:递归遍历所有的表
‘*****************************************************************************
 sub ProcessTables(folder)
   ‘处理模型中的表
   dim table
   for each table in folder.tables
     if not table.IsShortCut then
       on error resume next   

       ‘检查表名中是否有特殊字符、是否为关键字
       Check table.code, ""

       Dim col
       for each col in table.Columns
         ‘检查字段名中是否有特殊字符、是否为关键字
         Check col.code, table.code
       next
     end if
   next

   ‘对子目录进行递归
   dim subFolder
   for each subFolder in folder.Packages
     ProcessTables subFolder
   next
end sub

‘*****************************************************************************
‘过程:Check
‘功能:检查表名 或 字段名
‘*****************************************************************************
sub Check(str, tableCode)
  dim outStr
  if len(tableCode) > 0 then
    outStr = "字段名 " & tableCode & "."
  else
  	outStr = "表名 "
  end if

  ‘检查表明是否含有特殊字符
  if InStr(str, " ") then
    outStr = outStr & str & " 包含空格"
    Output outStr
  end if

  ‘是否包含中文
  if HasChinese(str) then
    outStr = outStr & str & " 包含中文"
    Output outStr
  end if

  ‘检测系统关键字
  dim arr
  arr = array("ADD","EXTERNAL","PROCEDURE","ALL","FETCH","PUBLIC","ALTER","FILE","RAISERROR","AND","FILLFACTOR","READ","ANY","FOR","READTEXT","AS","FOREIGN","RECONFIGURE","ASC","FREETEXT","REFERENCES","AUTHORIZATION","FREETEXTTABLE","REPLICATION","BACKUP","RESTORE","BEGIN","FULL","RESTRICT","BETWEEN","FUNCTION","RETURN","BREAK","GOTO","REVERT","BROWSE","GRANT","REVOKE","BULK","GROUP","RIGHT","BY","HAVING","ROLLBACK","CASCADE","HOLDLOCK","ROWCOUNT","CASE","IDENTITY","ROWGUIDCOL","CHECK","IDENTITY_INSERT","RULE","CHECKPOINT","IDENTITYCOL","SAVE","CLOSE","IF","SCHEMA","CLUSTERED","IN","SECURITYAUDIT","COALESCE","INDEX","SELECT","COLLATE","INNER","SEMANTICKEYPHRASETABLE","COLUMN","INSERT","SEMANTICSIMILARITYDETAILSTABLE","COMMIT","INTERSECT","SEMANTICSIMILARITYTABLE","COMPUTE","INTO","SESSION_USER","CONSTRAINT","IS","SET","CONTAINS","JOIN","SETUSER","CONTAINSTABLE","KEY","SHUTDOWN","CONTINUE","KILL","SOME","CONVERT","LEFT","STATISTICS","CREATE","LIKE","SYSTEM_USER","CROSS","LINENO","TABLE","CURRENT","LOAD","TABLESAMPLE","CURRENT_DATE","MERGE","TEXTSIZE","CURRENT_TIME","NATIONAL","THEN","CURRENT_TIMESTAMP","NOCHECK","CURRENT_USER","NONCLUSTERED","TOP","CURSOR","NOT","TRAN","DATABASE","NULL","TRANSACTION","DBCC","NULLIF","TRIGGER","DEALLOCATE","OF","TRUNCATE","DECLARE","OFF","TRY_CONVERT","DEFAULT","OFFSETS","TSEQUAL","DELETE","ON","UNION","DENY","OPEN","UNIQUE","DESC","OPENDATASOURCE","UNPIVOT","DISK","OPENQUERY","UPDATE","DISTINCT","OPENROWSET","UPDATETEXT","DISTRIBUTED","OPENXML","USE","DOUBLE","OPTION","USER","DROP","OR","VALUES","DUMP","ORDER","VARYING","ELSE","OUTER","VIEW","END","OVER","WAITFOR","ERRLVL","PERCENT","WHEN","ESCAPE","PIVOT","WHERE","EXCEPT","PLAN","WHILE","EXEC","PRECISION","WITH","EXECUTE","PRIMARY","WITHIN GROUP","EXISTS","PRINT","WRITETEXT","EXIT","PROC")
  for each keyword in arr
    if UCase(str) = keyword then
      outStr = outStr & str & " 为系统关键字"
      Output outStr
    end if
  next 

  ‘字符串长度是否超出限制
  if Len(str) >= 116 then
    outStr = outStr & str & " 命名的长度不应超过116"
    Output outStr
  end if
end sub

‘*****************************************************************************
‘函数:HasChinese
‘功能:是否包含中文
‘*****************************************************************************
function HasChinese(str)
  HasChinese = false 

  dim i
  for i=1 to Len(str)
    if Asc(Mid(str,i,1)) < 0 then
      HasChinese = true
      exit for
    end if
  next
end function
时间: 2024-10-10 17:17:53

PowerDesigner中遍历物理模型中的所有表,检查表代码、字段代码的相关文章

Oracle中使用游标获取指定数据表的所有字段名对应的字符串

操作步骤:打开PLSQL Developer后,直接执行下面的语句就可以出来 --Oracle中使用游标获取指定数据表的所有字段名对应的字符串 declare mytablename VARCHAR(255):='STAFFDOC'; --定义要查询的数据表名变量,STAFFDOC为我测试用的数据表名,请修改成您的数据库中的对应数据表名字mystring NVARCHAR2(4000):=''; --定义要输出的字符串变量 cursor mycursor is --定义游标          s

MySQL 中的数据库名称、数据表名称、字段名称

如何查询Oracle,Sql Server,MySQL 中的数据库名称.数据表名称.字段名称 分类: Database2012-09-24 22:16 7034人阅读 评论(0) 收藏 举报 数据库sql serveroraclemysqltableobject 目录(?)[+] 在开发项目的时候有个功能需要查看数据库中有哪些表,以及每个表有哪些字段,在网上查看了一下,现在分享给大家. Oracle: 查询数据表(Tables)名称:select Table_Name, Tablespace_N

SqlServer中获取所有数据库,所有表,所有字段

原文:SqlServer中获取所有数据库,所有表,所有字段 一.获取所有数据库 select * from master.dbo.SysDatabases 二.获取某个库中所有表 SELECT * FROM SysObjects Where XType='U' --XType='U':表示所有用户表; --XType='S':表示所有系统表; 三.获取某表中的字段,字段类型等 SELECT * FROM INFORMATION_SCHEMA.columns WHERE TABLE_NAME='C

关于C#中遍历字符串中的每个字符的方法

解决方案 C#提供了两个方法用于遍历字符串. 1.第一个方法是foreach循环,这个方法快速且容易,但是与第二个方法相比它不太灵活.其使用方法如下: string testStr = "abc123"; foreach (char c in testStr) { Console.WriteLine(c.ToString()); } 2.第二个方法使用for循环而不是foreach循环来遍历字符串.例如: string testStr = "abc123"; for

使用vue中的v-for在模板中遍历数组中的数组

接口返回数据, 需要每一项的数据, 刚开始不知道怎么取rule中的数据, 在methods中处理了好久, 后来发现一个好方法, 可以在模板中遍历嵌套遍历: 红色框中遍历外层数据, 黄色框中可以继续遍历,取出rule中的数据; 数据处理如下: 效果图: 灰色框中是数组rule中的数据 原文地址:https://www.cnblogs.com/Shysun/p/9745916.html

union 时只能查出一个表中的信息,另一个表只能查出字段

原因:news表中title字段的编码,与brand表中的编码不一致导致 y 原文地址:https://www.cnblogs.com/lxwphp/p/8329241.html

SQLServer中获取所有数据库名、表名、字段名以及描述

1. 获取所有的数据库的信息 SELECT * FROM MASTER.DBO.SYSDATABASES 2. 获取所有数据表名 XTYPE U 代表用户创建的表 S 代表系统表 SELECT * FROM sys.SYSOBJECTS WHERE XTYPE='U' 3. 查看某表内的所有列 SELECT * FROM sys.SYSCOLUMNS WHERE ID IN (SELECT ID FROM sys.SYSOBJECTS WHERE XTYPE='U' AND NAME = '表名

在 jsp页面中遍历list中的数据

往往我们都会将查询到的数据显示到界面中,那么该如何在界面显示,请看下面的详解: 0)前提得在jsp页面中获取后台传过来的数据(在此为List集合): <% List itemCategoryList=(List)request.getAttribute("itemCategoryList"); %> 往往在前台显示的时候回使用三种方式,一个是使用for循环,另一个是使用循环迭代器iterator,最后还有一种是使用JSTL.下面分别来看如何进行操作: 1)使用for循环方式

JavaScript中遍历数组中元素的两种方法

2015-03-27 20:02:20 <!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="Generator" content="EditPlus®"> <meta name="Author" content="">