powerdesigner使用vba脚本创建物理模型的表和列
程序员文章站
2022-05-10 12:10:05
...
试一下用脚本生成物理模型的表和列,不在设计视图操作和设计界面录入内容,看能否提高生产力;
选择菜单,Tools - Execute Commands - Edit/Run Script...;在弹出的对话框输入代码;
Set mdl = ActiveModel
set table = mdl.Tables.CreateNew
table.Name = "cammng"
table.Code = "cammng"
table.Comment = "摄像头管理"
set col1 = table.Columns.CreateNew
col1.Name = "camcd"
col1.Code = "camcd"
col1.Comment ="摄像头编码"
col1.Primary = true
col1.datatype = "varchar(32)"
set col2 = table.Columns.CreateNew
col2.Name = "camname"
col2.Code = "camname"
col2.Comment ="摄像头名称"
col2.datatype = "varchar(80)"
set col3 = table.Columns.CreateNew
col3.Name = "camplot"
col3.Code = "camplot"
col3.Comment ="摄像头端口"
col3.datatype = "varchar(24)"
set col4 = table.Columns.CreateNew
col4.Name = "lgtd"
col4.Code = "lgtd"
col4.Comment ="经度"
col4.datatype = "numeric(8,6)"
set col5 = table.Columns.CreateNew
col5.Name = "lttd"
col5.Code = "lttd"
col5.Comment ="纬度"
col5.datatype = "numeric(8,6)"
运行,没有提示出错;看一下左侧table列表,要建的表已经出来了;
但是设计界面上看不到;右击cammng表,Find in Diagram;
提示如下信息;就是代码生成了表,但是还没有代码生成设计视图上的symbol;
看一下脚本生成的,表和列、主键,和在设计界面录入的是一样效果;
暂时不知道如何用代码生成symbol,下回再整;
从工具箱拖一个Table的symbol放到设计界面;
再从左侧table列表把cammng表拖到前面放入的symbol,然后设计界面也有cammng表了;