我对 PL/SQL 游戏还很陌生,我正在尝试编写一个简短的脚本来创建登录名并授予只读/读写权限(根据需要进行必要的授予)。但是,我遇到了变量范围问题。有人可以帮助我可能做错了什么吗?
截图如下:
DECLARE CNT INTEGER;
BEGIN
SELECT COUNT(*)
INTO CNT
FROM dba_users
WHERE username = :ParamUserName
IF (CNT > 0) THEN
IF (INSTR(:ParamSelectedRole, 'WRITE') = 0) THEN
REVOKE UNLIMITED TABLESPACE FROM :ParamUserName;
REVOKE READ_WRITE FROM :ParamUserName;
GRANT READ_ONLY TO :ParamUserName;
ELSE
GRANT UNLIMITED TABLESPACE TO :ParamUserName;
END IF;
ELSE
CREATE USER :ParamUserName DEFAULT TABLESPACE USERS TEMPORARY TABLESPACE TEMP IDENTIFIED BY ":ParamUserPassword" PROFILE ELEV_USER;
ALTER USER :ParamUserName PASSWORD EXPIRE;
GRANT :ParamSelectedRole TO :ParamUserName;
GRANT CREATE SESSION TO :ParamUserName;
IF (INSTR(:ParamSelectedRole, 'WRITE') > 0 ) THEN
GRANT UNLIMITED TABLESPACE TO :ParamUserName;
END IF;
END IF;
END;
我正在使用 ODP.NET 进行变量分配并使用OracleCommand.Parameters.Add()