PowerDesigner在VB中创建表格授权

时间:2017-03-02 10:19:44

标签: powerdesigner

我试图创建一个脚本来自动授予特定用户选择,更新,删除和插入表格。

Dim ModelTables, table, tab, newPerm
SET ModelTables = obj.Tables

For Each table in ModelTables

  If IsObject(table) Then
     Set tab = table

     'Testing just on one table
     If InStr(tab.Name, "MY_TEST_TABLE")=1 Then

         set newPerm = tab.Permissions.createNew()
         '-- this is all I managed to create

     End If
  End if
Next

这是我设法创造的全部内容。我不知道权限的结构。我也是VB的新手。有人可以用提示/正确的代码/文档来支持我吗?

1 个答案:

答案 0 :(得分:0)

以下是创建新权限的示例,并列出现有权限。

option explicit
dim obj
set obj = activemodel
dim ModelTables : set ModelTables = obj.Tables
dim u : set u = Finduser("User_1")
if not u is nothing then
   dim table
   For Each table in ModelTables
      If IsObject(table) Then
         dim tab
         Set tab = table
         dim p
         if tab.Permissions.count = 0 then
            output "creating permission on " & tab.name
            set p = tab.Permissions.createNew
            set p.DBIdentifier = u
            p.grant = "SELECT,DELETE,INSERT,UPDATE"
         end if
         ' show permissions
         output "permissions on " & tab.name
         for each p in tab.Permissions
            output "   for user " & p.DBIdentifier & " : " & p.grant
         next
      End if
   Next
end if

function FindUser(name)
   dim u
   for each u in activemodel.users
      if u.name = name then
         set FindUser = u
         output "found user"
      end if
   next
end function