首页 > 解决方案 > How to write connect user/password in procedure in oracle?

问题描述

I try to create a procedure to allow the user (with the username 'c##administrator' and password 'addm')to login into the oracle using the connect <user_name>/<password_name> like this. But it said that click here to see the errors that oracle said. When I try to detect what is wrong on my script, I realize that the script cannot execute the command EXECUTE IMMEDIATE 'connect c##administrator/addm;'; and said that it is invalid sql command :<. But I don't know why it said that. I'm sure my password and my username is both correct.

Please help me fix it :( Thank you so much

CREATE OR REPLACE PROCEDURE system.SYS_KTraTaiKhoanAdmin (adUsername IN varchar2, adPassword IN varchar2)
IS
    ex EXCEPTION;
BEGIN
    IF (adUsername != 'c##administrator' AND adPassword != 'addm') THEN
        dbms_output.put_line('PLEASE LOG IN AGAIN');
    ELSE
        dbms_output.put_line('LOG IN SUCCESSFULLY!');
        EXECUTE IMMEDIATE 'connect c##administrator/addm;';
    END IF;
    EXCEPTION 
        WHEN ex THEN
           Raise_application_error(-1, 'Error');
END;
/
BEGIN
  system.SYS_KTraTaiKhoanAdmin('c##administrator', 'addm');
--rollback; 
END;
/

标签: databaseoracleoracle-sqldeveloper

解决方案


推荐阅读