Powerdesigner adds the name item to comment, the perfect solution!

Source: Internet
Author: User
Tags powerdesigner

I wrote a blog for the first time and shared some experience. When using powerdesigner, PD does not add the name item to the comment by default, therefore, the generated database table does not contain comments for Chinese fields.

I checked it online. There is a solution.

The following is an online solution. I have improved it.

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

Save the script name2comment. vbs.

' Add the name in the PD to the comment automatically.
' If the comment is empty, enter the name. If it is not empty, the comment remains unchanged. This avoids the loss of existing comments.

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   If  Trim(Tab. Comment)="" Then ' If a table comment exists, it is not changed. If no table comment exists, the name is added to the comment.
Tab. Comment = Tab. Name End If  
Dim Col ' Running Column
For Each Col in tab. Columns
If   Trim (Col. Comment) = ""   Then   ' If the col comment is empty, enter the name. If there are comments, do not add them. This avoids the loss of existing comments.
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

After we design the database, execute it again. OK. All the Description fields of your database are available. Is it very convenient!

 

 

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.