powerDesigner PDM格式导出常见问题

cdm转成pdm,CTRL+SHIFT+C

pdm生成SQL,CTRL+G

 

报错:table code maximum length

 

一。通过调整以下两个参数,
菜单:Database=>Edit current DBMS
PGSQL73::Script\Objects\MaxConstLen
value=>255

PGSQL73::Script\Objects\Table\Maxlen
value=>255
可以避免在生成sql时的错误:

Reference constraint name maximum length is limited to 7 characters
Key constraint name maximum length is limited to 7 characters
Table code maximum length

这个问题很有普遍性,公司三四个同事都遇到,因没有做笔记,而且这个设置比较隐蔽,很快就忘记,所以每次都花了好长时间才找回设置的地方,为此,做下笔记,并特意把错误提示信息也写上,方便搜索。

二。生成数据库脚本
1.改变目标数据库
菜单:Database=>Change current DBMS
2.生成脚本
菜单:Generate database

 

 

 

powerDesigner 中的 NAME 转 COMMENT

 

在使用PowerDesigner设计PDM时,一般输入NAME和CODE,因为大部分的COMMENT和NAME相同,也懒得再输入一遍.但是PD本身并没有提供映射的函数.以下是我根据name2code.vbs修改的映射函数.
基本实现思想:
1,迭代所有的表,表字段,视图
2,如果他们的COMMENT为空,则将其赋值为NAME+"。"
3,如果他们的COMMENT不为空,则在COMMENT中搜索"。",取"。"之后的字符串(假设为RC),如果没有找到"。"则RC等于COMMENT
4,新的COMMENT值为:NAME+"。"+RC

使用建议:鉴于上述的实现,NAME不要包含"。",在使用时如果第一次手工输入的COMMENT时,将COMMENT的第一个字符输入为"。"最好.否则可能会因为COMMENT中有"。"或NAME中有"。"而出现偏差.
执行方式:打开要映射的DIAGRAM,然后菜单TOOLS->Excute Commands->Edit/Ran Script...将下面的代码COPY/PASTE进去,然后点击执行即可.

代码如下:[name2comment.vbs]
''******************************************************************************

Option Explicit
ValidationMode = True
InteractiveMode = im_Batch

Dim mdl ' the current model
Dim i
dim splitNC
dim splitIdx
dim newComment
dim commentLen
' get the current active model
splitNC="。"'name and comment split string
splitIdx=0
newComment=""
commentLen=0

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 copies the name into code for each table, column and view
' of the current folder
Private sub ProcessFolder(folder)
Dim Tab 'running table
Dim rc 'return code

for each Tab in folder.tables
if not tab.isShortcut then
MergeNameComment tab'tab.Comment=tab.Name
Dim col ' running column
for each col in tab.columns
MergeNameComment col'col.Comment=col.Name
next
end if
next

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

private sub MergeNameComment(obj)
if obj.Comment = "" then
obj.Comment = obj.Name & splitNC
else
splitIdx=instr(obj.Comment,splitNC)
if splitIdx >= 0 then
commentLen=len(obj.Comment)
obj.Comment=obj.Name & splitNC & right(obj.Comment,commentLen-splitIdx)
end if
end if
end sub

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值