set serveroutput on;
declare
username1 varchar2(40);
cnt number;
hello varchar2(20);
c sys_refcursor;
begin
select sys_context('userenv','session_user') into username1 from dual;
select lower(username1) into username1 from dual;
select count(lower(username)) into cnt from karuna.tableusers where lower(username)=username1;
if cnt=1 then
dbms_output.put_line('username found');
execute immediate 'connect karuna/password ';
open c for 'select item_name from sells12 where item_id=12';
fetch c into hello;
dbms_output.put_line(hello);
close c;
else
dbms_output.put_line('u dont have previllege to access database');
----raise_application_error(-20001,'error out');
end if;
end;
/
我想切换会话用户,但我在connect karuna / karuna line
收到错误答案 0 :(得分:0)
查看Oracle的功能n层(代理)身份验证。也许它不是你需要的。 Oracle为您提供:
正确的选择实际上取决于您的需求。
答案 1 :(得分:0)
您必须提供dba权限才能从您的用户连接到KARUMA用户或CONNECT权限。
请点击此链接 http://docs.oracle.com/cd/B28359_01/java.111/b31224/proxya.htm