Discussion:
Seeking help in VB Script to Rename the Foreign Keys in a PDM.
(too old to reply)
Prabhash Dubey
2014-04-07 18:05:09 UTC
Permalink
Hi, I need a little help in my VB Script pasted below). I get an error 0x800a01c2 at run-time.
I developed this script to rename the Foreign Keys.
Please see the script below. Looking forward for some help. Thanks.

Option Explicit


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
ProcessReferences mdl
ShowProperties mdl
End If

Private sub ProcessReferences(folder)
Dim Tab, Key, Ref
for each Ref in folder.References
Output Ref.ForeignKeyColumnList
next
end sub

Sub ShowProperties(Package)
' Get the Tables collection
Dim ModelTables
Set ModelTables = Package.References

Dim col
Dim Ref
Dim firstString 'as string
Dim CompleteString

For Each Ref in Package.References
If left(Ref.ForeignKeyColumnList,4) = "VER_" Then
Ref.ForeignKeyColumnList = Mid(Ref.ParentTable.Code,5) + "_" + "EID"
End If
End If
Next

Dim subpackage
For Each subpackage in package.Packages
If Not subpackage.IsShortcut Then
ShowProperties subpackage
End If
Next
End Sub
Prabhash Dubey
2014-04-07 21:08:05 UTC
Permalink
Post by Prabhash Dubey
Hi, I need a little help in my VB Script pasted below). I get an error 0x800a01c2 at run-time.
I developed this script to rename the Foreign Keys.
Please see the script below. Looking forward for some help. Thanks.
We are using PowerDesigner 16.1 with Oracle 11g.
Option Explicit
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
ProcessReferences mdl
ShowProperties mdl
End If
Private sub ProcessReferences(folder)
Dim Tab, Key, Ref
for each Ref in folder.References
Output Ref.ForeignKeyColumnList
next
end sub
Sub ShowProperties(Package)
' Get the Tables collection
Dim ModelTables
Set ModelTables = Package.References
Dim col
Dim Ref
Dim firstString 'as string
Dim CompleteString
For Each Ref in Package.References
If left(Ref.ForeignKeyColumnList,4) = "VER_" Then
Ref.ForeignKeyColumnList = Mid(Ref.ParentTable.Code,5) + "_" + "EID"
End If
End If
Next
Dim subpackage
For Each subpackage in package.Packages
If Not subpackage.IsShortcut Then
ShowProperties subpackage
End If
Next
End Sub
Loading...