When you use PowerDesigner to make conceptual and physical model designs for a database, you typically write Chinese in name or comment and write English in code. Name is used to show that code is used in codes, but the text in comment is saved to the comment of the database table or column, and when name already exists, it is cumbersome to write again comment, you can use the following code to solve the problem
The methods used in PowerDesigner are:
Powerdesigner->tools->execute Commands->edit/run Scripts
Copy the code in to execute it, it is the entire CDM or PDM operation
[VB]View Plaincopyprint?' Code one: Copy the characters in name to comment
- 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 isn't an physical Data model."
- Else
- ProcessFolder MDL
- End If
- ' This routine copy name to comment for each table, each column and each view
- ' of the current folder
- Private Sub ProcessFolder (folder)
- Dim Tab ' running table
- For all Tab in Folder.tables
- If not Tab.isshortcut then
- Tab.comment = Tab.name
- Dim Col ' running column
- For each col in Tab.columns
- Col.comment= Col.name
- Next
- End If
- Next
- Dim View ' running view
- For each view in folder. Views
- If not View.isshortcut 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
In addition, when using reverse engineer to reverse-generate PDM from the database, the name and code of the table in PDM are in fact code, and in order to replace name with the Chinese comment of table or column in the database, the following script can be used:
[VB]View Plaincopyprint?
- ' Code two: Copy the characters in the comment to 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 isn't an physical Data model."
- Else
- ProcessFolder MDL
- End If
- Private Sub ProcessFolder (folder)
- On Error Resume Next
- Dim Tab ' running table
- For all 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
- Original address: http://blog.csdn.net/smartsmile2012/article/details/7922863
Turn-powerdesigner copy comment to name and copy name to comment