3

In Powerdesign would like to create a VBscript to rename/reform the following names in powerdesigner- Conceptural or Physical model

Alternative/Unique Key Name:

UQ {table_name} {tablecolumnname} /////// Example = UQ_Account_AccountNumber

Relationship Name:

FK_{table_name}_{reference_table_name}_{reference_column_name} //////Example = FK_Account_AccountPhone_HomePhoneID

Problem is, how do I get the "table_column_name" and "reference_column_name"?

001
  • 62,807
  • 94
  • 230
  • 350
  • Useful: http://blogs.conchango.com/danperrin/archive/2008/07/11/sybase-powerdesigner-scripting.aspx – 001 May 08 '09 at 01:19

1 Answers1

2

Here's something I used to rename the 'friendly' names, plus the constraint names of all my references. Maybe it will help you out.

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
Calvin Allen
  • 4,176
  • 4
  • 31
  • 31