PowerDesigner 把Comment寫到name中 和把name寫到Comment中 pd7以后版本可用


另外在字段中 把 Identity 和ExtIdentitySeedInc 都顯示出來,勾選 Identity列,並在 ExtIdentitySeedInc 填入: 1,1 就可以實現 自增標識列了
 
本解決方案背景:  
    1. 由於PDM 的表中 Name 會默認=Code 所以很不方便, 所以需要將 StereoType 顯示到表的外面來,然后再將 StereoType 的值更新到 Comment 列中 來實現,即在外面圖型界面顯示中文,又能將中文備注添加到 sql2000 或是 sql2005 的字段說明中顯示,
 
解決方案:
  第一步: 將 StereoType 顯示在圖形界面上,並隱藏原先Name 屬性
   1.1 打開[工具]->[顯示屬性](英文:Display Preferences) ->Content->Table->右邊面板Columns框中 勾選: StereoType ,這樣再在 StereoType中填入中文字段說明就會顯示在圖形界面上了.
      第二步: 將 StereoType 顯示在表字段添加界面.
      第三步: 將以下代碼在 菜單:工具-> Execute Commands -> Edit/Run Script.... 中執行(這樣就會把 StereoType 中的值賦給 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.isShortcut   then 
                  tab.comment   =   tab.StereoType
                  Dim   col   '   running   column 
                  for   each   col   in   tab.columns 
                        col.comment=   col.StereoType 
                  next 
            end   if 
      next

      Dim   view   'running   view 
      for   each   view   in   folder.Views 
            if   not   view.isShortcut   then 
                  view.comment   =   view.StereoType 
            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

然后導出就完事了.....

然后再看我博客里的一篇顯示 表字段和說明等等的一段腳本,就完美了...

 

 

 
摘自網絡,供自己以后備查使用.
 
在使用PowerDesigner對數據庫進行概念模型和物理模型設計時,一般在NAME或Comment中寫中文,在Code中寫英文。Name用來顯 示,Code在代碼中使用,但Comment中的文字會保存到數據庫Table或Column的Comment中,當Name已經存在的時候,再寫一次 Comment很麻煩,可以使用以下代碼來解決這個問題:
  • 代碼一:將Name中的字符COPY至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.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

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

         另外在使用REVERSE ENGINEER從數據庫反向生成PDM的時候,PDM中的表的NAME和CODE事實上都是CODE,為了把NAME替換為數據庫中Table或Column的中文Comment,可以使用以下腳本:

  • 代碼二:將Comment中的字符COPY至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.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

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

以上兩段代碼都是VB腳本,在PowerDesigner中使用方法為:

    PowerDesigner->Tools->Execute Commands->Edit/Run Scripts

將代碼Copy進去執行就可以了,是對整個CDM或PDM進行操作


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM