3

在 Powerdesign 中想创建一个 VBscript 来重命名/修改 powerdesigner 中的以下名称-概念或物理模型

替代/唯一键名:

UQ {table_name} {tablecolumnname} /////// 示例= UQ_Account_AccountNumber

关系名称:

FK_{table_name}_{reference_table_name}_{reference_column_name} //////示例= FK_Account_AccountPhone_HomePhoneID

问题是,如何获得“table_column_name”和“reference_column_name”?

4

1 回答 1

2

这是我用来重命名“友好”名称的东西,以及我所有引用的约束名称。也许它会帮助你。

Option Explicit
ValidationMode  = True
InteractiveMode = im_Batch

Dim mdl 
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 a Physical Data model."
Else
   ProcessFolder mdl
End If

Private sub ProcessFolder(folder)
   Dim Tab, Key, Rel
   for each Rel in Folder.References
      Rel.ForeignKeyConstraintName = "FK_" + UCASE(Rel.ParentTable.Name) + "_" + UCASE(Rel.ParentKeyColumnList) + "_" + UCASE(Rel.ChildTable.Name) + "_" + UCASE(Rel.ForeignKeyColumnList)
      Rel.Name = "FK_" + UCASE(Rel.ParentTable.Name) + "_" + UCASE(Rel.ParentKeyColumnList) + "_" + UCASE(Rel.ChildTable.Name) + "_" + UCASE(Rel.ForeignKeyColumnList)
   next
end sub
于 2009-05-13T02:12:06.913 回答