首页 > 代码库 > 将CDM中所有以Relatonship_开头的关系全部重命名,避免生成数据库因为重复关系名报错
将CDM中所有以Relatonship_开头的关系全部重命名,避免生成数据库因为重复关系名报错
Option Explicit
ValidationMode = True
InteractiveMode = im_Batch
Dim mdl ‘当前model
‘获取当前活动model
Set mdl = ActiveModel
If (mdl Is Nothing) Then
MsgBox "There is no current Model "
ElseIf Not mdl.IsKindOf(PdcDM.cls_Model) Then ‘如果是处理pdm,这里换成PdPDM.cls_Model
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 ref ‘要处理的对象
for each ref in folder.relationships
if not ref.isShortcut then
if instr(lcase(ref.code),"relationship_") =1 then
ref.code=ref.entity1.name+"2"+ref.entity2.name
ref.name=ref.code
end if
end if
next
‘递归遍历子文件夹
Dim f ‘子文件夹
For Each f In folder.Packages
if not f.IsShortcut then
ProcessFolder f
end if
Next
end sub
将CDM中所有以Relatonship_开头的关系全部重命名,避免生成数据库因为重复关系名报错