在PowerDesigner中将Comment字段复制到Name字段,总是出错!

angle097113 2007-08-20 04:36:47
在网站上找到一段代码,如下:
'******************************************************************************
'* File: name2comment.vbs
'* Purpose: Database generation cannot use object names anymore
' in version 7 and above.
' It always uses the object codes.
'
' In case the object codes are not aligned with your
' object names in your model, this script will copy
' the object Name onto the object comment for
' the Tables and Columns.
'
'* Title: 把对象comment拷入name属性中
'* Version: 1.0
'* Author:wangnc
'* 执行方法:PD11 -- Open PDM -- Tools -- Execute Commands -- Run Script
'******************************************************************************

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 code 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.name=tab.comment
Dim col ' running column
for each col in tab.columns
col.name=tab.comment
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
--------------------------------------------------
但是执行时候总是提示“Column (Exception occurred. (0x80020009))At line 43”
大家帮帮忙,谢谢!
...全文
371 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
byfq 2007-11-15
  • 打赏
  • 举报
回复
学习一下
cerwg 2007-10-10
  • 打赏
  • 举报
回复
'******************************************************************************
'* File: name2comment.vbs
'* Purpose: Database generation cannot use object names anymore
' in version 7 and above.
' It always uses the object codes.
'
' In case the object codes are not aligned with your
' object names in your model, this script will copy
' the object Name onto the object Comment for
' the Tables and Columns.
'
'* Title:
'* Version: 1.0
'* Company: Sybase Inc.
'******************************************************************************


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
zuiaihl911 2007-09-11
  • 打赏
  • 举报
回复
联通把156拼成"吉"字,实则是采用了草书的写法,今天我用他的方法拼了拼我的生日,原来是个"好"字,看看有谁能猜出我的生日?
beyondrobey 2007-09-08
  • 打赏
  • 举报
回复
应为NAME是不能重复的,要使用VBScript脚本的错误处理,忽略掉产生重复的
qiubolecn 2007-08-27
  • 打赏
  • 举报
回复
col.name=tab.comment
为什么要这样。。。。

col.name=col.comment吧

2,596

社区成员

发帖
与我相关
我的任务
社区描述
Sybase相关技术讨论区
社区管理员
  • Sybase社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧