导出字段等信息(在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
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