powerdesigner导出字段信息的vba脚本

导出字段等信息(在pd中执行如下脚本,部分地方需要修改)
Option Explicit
ValidationMode = True
InteractiveMode = im_Batch

'on error resume next

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 code for each table, each column and each view
' of the current folder
Private sub ProcessFolder(folder)
   Dim tab 'running  table  
   Dim col 'running column
   Dim v_datatype,v_length,v_precision,v_primarykey,v_null,v_flag
   Dim text
   Dim system, file
   Set system = CreateObject("Scripting.FileSystemObject")

  ' Open mode constants...
  Dim ForReading, ForWriting, ForAppending
  ForReading   = 1 ' Open a file for reading only. You can't write to this file.
  ForWriting   = 2 ' Open a file for writing.
  ForAppending = 8 ' Open a file and write to the end of the file.


  Set file = system.OpenTextFile("E:\export.log", ForAppending, true)
   for each tab in folder.tables
      if not tab.isShortcut Then
           IF instr(tab.code,"cust")>0 THEN
           for each col in tab.columns
                if col.Primary=true then '主键判断
                     v_primarykey = 1
                     v_null= 0
                else
                     v_primarykey = 0
                     v_null= 1
                end if
               
                v_dataType = uCase(Col.DataType)
                v_length = col.length  '取数据类型长度
                v_precision= col.precision  '取数据类型精度
               
                if  instr(v_dataType,"VARCHAR")>0 Then   '数据类型判别
                     v_dataType = 12
                elseif instr(v_dataType,"DECIMAL")>0 Then
                     v_dataType = 3
                elseif  instr(v_dataType,"INTEGER")>0 Then
                     v_dataType = 4
                end if
               
                'if v_dataType = 4 then
                '     v_length =16
                '     v_precision = 3
                'end if
               
            
                text = tab.code&":"&col.code&":"&v_datatype&":"&v_length&":"&v_precision&":"&v_primarykey&":"&v_null&":"&col.code&":"&v_flag&vbCrLf
                    file.Write text
           
               next
               end if
      end if
   Next
   file.Close
   output "处理结束!"
end sub
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值