我在APEX 5中传递会话替换字符串时遇到一些困难。
我的APEX应用程序中有一个进程,它将更改远程数据库上用户的密码。用户名是通过本地LDAP身份验证设置的,因此保存在APEX替换字符串中:APP\u USER
我想将此字符串传递到远程数据库,以便更改当前登录用户的密码(
希望这有意义!
)
当按下APEX页面上的“更改密码”按钮时,我会执行此过程:
DECLARE
cursor_handle INTEGER;
cursor_handle_tmp INTEGER;
BEGIN
-- Open a Cursor on the REMOTE database
cursor_handle := DBMS_SQL.OPEN_CURSOR@remote_db;
-- Parse the "change password"
DBMS_SQL.PARSE@remote_db(cursor_handle,'ALTER USER MYUSER IDENTIFIED BY mypassword',DBMS_SQL.NATIVE);
-- Execute the cursor
cursor_handle_tmp := DBMS_SQL.EXECUTE@remote_db(cursor_handle);
-- Close the cursor
DBMS_SQL.CLOSE_CURSOR@remote_db(cursor_handle);
END;
这执行得很好,因为概念证明用户和密码都是硬编码的,远程用户的密码按预期更改。
但是,如果随后使用替换字符串:APP\u USER和:P111\u PASSWORD,则会收到错误消息:
missing user or role name
这意味着字符串没有正确传递到远程DB。
如果我使用v函数v('APP\u USER'),我的代码将无法在编辑器中正确验证,因为APEX会将其标记为以下错误:
DBMS_SQL.PARSE@passman_bandev(cursor_handle,'ALTER USER v('APP_USER') IDENTIFIED BY P111_RE_PASSWORD',DBMS_SQL.NATIVE);
ORA-06550: line 11, column 63: PLS-00103: Encountered the symbol "APP_USER" when expecting one of the following: ) , * & = - + < / > at in is mod remainder not rem => <an exponent (**)> <> or != or ~= >= <= <> and or like like2 like4 likec between || multiset member submultiset The symbol ", was inserted before "APP_USER" to continue.
所以看起来我可能没有正确地转义必要的字符?
然而,我尝试了许多不同的可能组合,但都没有成功。