PowerDesigner:16

文章目录

简介

PowerDesigner 通过脚本对表模型批量添加字段

脚本

Option Explicit
 
Dim mdl ' the current model
Set mdl = ActiveModel
Dim Tab 'running table
Dim col_1 
Dim col_2 
Dim col_3 
Dim col_4 
Dim col_5 

 
' 定义属性变量
for each Tab in ActiveModel.Tables
   if Tab.name="Table_2" then
		Set col_1  = Tab.Columns.CreateNew
		Set col_2  = Tab.Columns.CreateNew
		Set col_3  = Tab.Columns.CreateNew
		Set col_4  = Tab.Columns.CreateNew
		Set col_5  = Tab.Columns.CreateNew
	
	
		'添加公共字段 by Sinu
		col_1.name = "order_day_moved0"
		col_2.name = "外部单据号"
		col_3.name = "抹零差异"
		col_4.name = "已付金额"
		col_5.name = "收货地址"
		
		col_1.code = "order_day_moved0"
		col_2.code = "out_order_no"
		col_3.code = "wipe_zero_diff"
		col_4.code = "paid_amount"
		col_5.code = "shipping_addr_id"
		
		col_1.DataType = "varchar"
		col_2.DataType = "varchar"
		col_3.DataType = "numeric"
		col_4.DataType = "numeric"
		col_5.DataType = "int4"
	end if

next
MsgBox "success"

执行添加

选中模型执行 Ctrl+Shift+X:
在这里插入图片描述
给Table_2批量添加字段:
在这里插入图片描述

Logo

GitCode 天启AI是一款由 GitCode 团队打造的智能助手,基于先进的LLM(大语言模型)与多智能体 Agent 技术构建,致力于为用户提供高效、智能、多模态的创作与开发支持。它不仅支持自然语言对话,还具备处理文件、生成 PPT、撰写分析报告、开发 Web 应用等多项能力,真正做到“一句话,让 Al帮你完成复杂任务”。

更多推荐