Home PowerDesigner中name和comment的互相转换
Post
Cancel

PowerDesigner中name和comment的互相转换

在【Tools】-【Execute Commands】-【Edit/Run Script】下。输入下面你要选择的语句即可,也可以保存起来,以便下次使用,后缀为.vbs。需要注意的问题是:运行语句时必须在Module模式下,如果是导出报表时执行会出现错误提示。

name转到comment注释字段

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
'如果comment为空,则填入name;如果不为空,则保留不变,这样可以避免已有的注释丢失。
Option Explicit
ValidationMode = True
InteractiveMode = im_Batch

Dim mdl 'the current model

'get the current active model 
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 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 Tab 'running   table  
  For Each Tab In folder.tables
    If Not tab.isShortcut Then
    '如果有表的注释,则不改变它.如果没有表注释.则把name添加到注释里面
    If Trim(tab.comment) = "" Then 
    tab.comment = tab.name
    End If
    Dim col ' running column  
    For Each col In tab.columns
    '如果col的comment为空,则填入name,如果已有注释,则不添加;这样可以避免已有注释丢失
    If Trim(col.comment) = "" Then 
    col.comment = col.name
    End If
  Next
End If
Next

Dim view 'running view  
For Each view In folder.Views
If Not view.isShortcut And Trim(view.comment) = ""  Then
  view.comment = view.name
End If
Next

'go into the sub-packages  
Dim f 'running folder  
For Each f In folder.Packages
If Not f.IsShortcut Then
  ProcessFolder f
End If
Next
End Sub

comment注释字段转到name

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
Option Explicit
ValidationMode = True
InteractiveMode = im_Batch

Dim mdl 'the current model  

'get the current active model  
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 an Physical Data model. "
Else
  ProcessFolder mdl
End If

Private Sub ProcessFolder(folder)
  On Error Resume Next
  Dim Tab 'running table  
  For Each Tab In folder.tables
    If Not tab.isShortcut Then
    tab.name = tab.comment
    Dim col 'running column  
    For Each col In tab.columns
      If col.comment = "" Then
      Else
        col.name = col.comment
      End If
    Next
    End If
  Next
  
  Dim view 'running view  
  For Each view In folder.Views
    If Not view.isShortcut Then
    view.name = view.comment
    End If
  Next
  
  'go into the sub-packages  
  Dim f 'running folder  
  For Each f In folder.Packages
    If Not f.IsShortcut Then
    ProcessFolder f
    End If
  Next
End Sub

参考:PowerDesigner中NAME和COMMENT的互相转换,需要执行语句

This post is licensed under CC BY 4.0 by the author.