PowerDesigner writes Comment to name and writes name to Comment. pd7 and later versions are available.

Source: Internet
Author: User
Tags powerdesigner

When powerdesigner is used to design conceptual and physical models for databases, it generally writes Chinese in name or comment and English in code. Name is used to display
Code is used in the code, but the text in the comment is saved to the database table or column comment. If the name already exists, write it again.
Comment is very troublesome. You can use the following code to solve this problem:

  • Code 1: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 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. isw.cut 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. isw.cut 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. isw.cut then
    ProcessFolder f
    End if
    Next
    End sub

--------------------------------------------

In addition, when the reverse engineer is used to reverse generate PDM from the database, the name and code of the table in PDM are actually code. To replace the name with the Chinese comment of table or column in the database, you can use the following script:

  • Code 2:COPY the characters in 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 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. isw.cut 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. isw.cut 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. isw.cut then
    ProcessFolder f
    End if
    Next
    End sub

-----------------------------------------------------------------------

The above two sections of code are all VB scripts. The usage in powerdesigner is as follows:

Powerdesigner-> Tools-> execute commands-> edit/run scripts

Copy the code and execute it. The operation is performed on the entire CDM or PDM.

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.