Turn-powerdesigner copy comment to name and copy name to comment

Source: Internet
Author: User
Tags powerdesigner

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

  1. Option Explicit
  2. Validationmode = True
  3. Interactivemode = Im_batch
  4. Dim MDL ' the current model
  5. ' Get the current active model
  6. Set mdl = Activemodel
  7. If (MDL is nothing ) Then
  8. MsgBox "There is no current Model"
  9. ElseIf not mdl. IsKindOf (Pdpdm.cls_model) Then
  10. MsgBox "The current model isn't an physical Data model."
  11. Else
  12. ProcessFolder MDL
  13. End If
  14. ' This routine copy name to comment for each table, each column and each view
  15. ' of the current folder
  16. Private Sub ProcessFolder (folder)
  17. Dim Tab ' running table
  18. For all Tab in Folder.tables
  19. If not Tab.isshortcut then
  20. Tab.comment = Tab.name
  21. Dim Col ' running column
  22. For each col in Tab.columns
  23. Col.comment= Col.name
  24. Next
  25. End If
  26. Next
  27. Dim View ' running view
  28. For each view in folder. Views
  29. If not View.isshortcut then
  30. View.comment = View.name
  31. End If
  32. Next
  33. ' Go into the sub-packages
  34. Dim F ' running folder
  35. For each f in folder. Packages
  36. If not F.isshortcut then
  37. ProcessFolder F
  38. End If
  39. Next
  40. 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?
    1. ' Code two: Copy the characters in the comment to name
    2. Option Explicit
    3. Validationmode = True
    4. Interactivemode = Im_batch
    5. Dim MDL ' the current model
    6. ' Get the current active model
    7. Set mdl = Activemodel
    8. If (MDL is nothing ) Then
    9. MsgBox "There is no current Model"
    10. ElseIf not mdl. IsKindOf (Pdpdm.cls_model) Then
    11. MsgBox "The current model isn't an physical Data model."
    12. Else
    13. ProcessFolder MDL
    14. End If
    15. Private Sub ProcessFolder (folder)
    16. On Error Resume Next
    17. Dim Tab ' running table
    18. For all Tab in Folder.tables
    19. If not Tab.isshortcut then
    20. Tab.name = Tab.comment
    21. Dim Col ' running column
    22. For each col in Tab.columns
    23. If col.comment="" Then
    24. Else
    25. Col.name= col.comment
    26. End If
    27. Next
    28. End If
    29. Next
    30. Dim View ' running view
    31. For each view in folder. Views
    32. If not View.isshortcut then
    33. View.name = View.comment
    34. End If
    35. Next
    36. ' Go into the sub-packages
    37. Dim F ' running folder
    38. For each F in folder. Packages
    39. If not F.isshortcut then
    40. ProcessFolder F
    41. End If
    42. Next
    43. End Sub
    44. Original address: http://blog.csdn.net/smartsmile2012/article/details/7922863

Turn-powerdesigner copy comment to name and copy name to comment

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.