Skip to Content

Mapping 'Description' in physical tables to 'Comments' in database DDL

I am wanting the 'Definition' of physical model tables (rather than 'Comment') to be put in the 'comments' of the database DDL statements. Is there any way to achieve this?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Sep 27 at 08:04 AM

    It is, but be aware, that Definition properties (Description and Annotation) are RTF-enabled texts, so they are not appropriate for generating to DB. I`d rather recommend creating new extended attribute of type Text to suit your needs. Anyway, if you insist on using these RTF-based attributes in your DDL-generation templates, here is how you can achieve it:

    Go to menu Database - Edit current DBMS... then go to Script\Objects\Table\TableComment.

    Most probably you will have to use .vbscript macro, so you should modify the template in following way:

    comment on table [%QUALIFIER%]%TABLE% is 
    .vbscript
    ScriptResult = Rtf2Ascii(ActiveSelection.Item(0).Description)
    .endvbscript

    And if you need quotes there, some more modifications will be needed. But it depends on whether you are more familiar with GTL or VBS in PowerDesigner.

    Ondrej

    Add comment
    10|10000 characters needed characters exceeded

    • You are right, TableComment is hardcoded for Table.Comment only. In this case, it would be better to modify directly

      Script\Objects\Table\Create in following way:

      create [%Temporary% ]table [%QUALIFIER%]%TABLE% (
         %TABLDEFN%
      )
      [%OPTIONS%]
      
      
      .vbscript
      If Len(Rtf2Ascii(ActiveSelection.Item(0).Description)) > 0 then
      ScriptResult = "comment on " + ActiveSelection.Item(0).Code + " is '" + Rtf2Ascii(ActiveSelection.Item(0).Description) + "'"
      End If
      .endvbscript

      And if you want to get rid of generating comments into your DDL for good, you can either disable Comment generating in your Generation Options (Ctrl + G --> tab Options) or wipe the TableComment entry in the DBMS file.

      Ondrej

  • Sep 27 at 07:36 AM

    You could alter the database definition to read the Description property iinstead of the comment. For example, the Table Comment is in Script\Objects\Table\TableComment, and it looks like this for SQL Anywhere:

    comment on table [%QUALIFIER%]%TABLE% is [%COMMENT%?%.q:COMMENT%:null]

    You'll have to truncate it, I guess, and embed some vbscript to convert RTF to ASCII.

    Add comment
    10|10000 characters needed characters exceeded