我创建了一个LUA脚本,它创建了一个变量'roles',它运行一个SQL查询来获取一个包含一堆SQL语句的表。我有一个for循环遍历每个语句并每次执行它们然后我得到错误,我的'角色'变量被设置为布尔值。我试图手动将此变量设置为'table',但这并没有解决我的问题。
代码:
CREATE OR REPLACE LUA SCRIPT "GRANT_RT_MIBI_SUPPORT_ROLE_TO_SCHEMA" () RETURNS ROWCOUNT AS
--Create variable ROLES which stores all of the roles that will be assigned to a schema when ran.
roles = pquery([[SELECT
'GRANT CREATE SESSION TO RT_MIBI_SUPPORT;' AS ROLES_TO_GRANT
UNION ALL
SELECT
'GRANT SELECT ON ' || OBJECT_NAME || ' TO RT_MIBI_SUPPORT;' AS ROLES_TO_GRANT
FROM
SYS.EXA_DBA_OBJECTS
WHERE
OBJECT_NAME LIKE 'RT_MIBI%' AND OBJECT_TYPE = 'SCHEMA';]])
--Iterate through each of the roles until all roles have been executed.
for i = 1, #roles, 1 do
print(roles)
i = i + 1
print(roles)
end
/
非常感谢任何帮助:)