PowerDesigner VB 腳本


shift+ctrl+x執行

批量添加字段(無則添加)

Option Explicit

Dim mdl ' the current model   
Set mdl = ActiveModel 
Dim Tab 'running table   
Dim col_create_date, col_update_date,col_create_by,col_update_by,col_is_delete
' 定義屬性變量
for each Tab in mdl.Tables
	Dim col
	Dim has_create_date,has_update_date,has_create_by,has_update_by
	has_create_date=0
	has_update_date=0
	has_create_by=0
	has_update_by=0

	For Each col In Tab.columns
		If (col.code = "create_date") Then
		    has_create_date = 1
		End If
		If (col.code = "update_date") Then
		    has_update_date = 1
		End If
		If (col.code = "create_by") Then
		    has_create_by = 1
		End If
		If (col.code = "update_by") Then
		    has_update_by = 1
		End If
	Next


	If (has_create_date=0) Then

	       Set col_create_date = Tab.Columns.CreateNew
	         col_create_date.name = "創建時間"
		 col_create_date.code = "create_date"
		 col_create_date.comment = "創建時間"
		 col_create_date.DataType = "DateTime"
	End If
	If (has_update_date=0) Then

	        set col_update_date = Tab.Columns.CreateNew
		  col_update_date.name = "修改時間"
		 col_update_date.code = "update_date"
		 col_update_date.comment = "修改時間"
		 col_update_date.DataType = "DateTime"
	End If
	If (has_create_by=0) Then

	         set col_create_by = Tab.Columns.CreateNew
		 col_create_by.name = "創建人"
		 col_create_by.code = "create_by"
		 col_create_by.comment = "創建人"
		 col_create_by.DataType = "VARCHAR(32)"
	End If

	If (has_update_by=0) Then

	       set col_update_by = Tab.Columns.CreateNew
	        col_update_by.name = "更新人"
		 col_update_by.code = "update_by"
		 col_update_by.comment = "更新人"
		 col_update_by.DataType = "VARCHAR(32)"
	End If
next

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM