0
    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;

/

我想切换会话用户,但在连接 karuna/karuna 线路时出现错误

4

2 回答 2

1

查看 Oracle 的特性 n 层(代理)身份验证。也许这不是你需要的。Oracle 为您提供:

  • n 层认证
  • 设置角色声明(从密码“受保护”角色中获得更多特权)
  • 更改会话集 current_schema=KARUMA。这不会切换您的用户名/权限,而是切换默认架构。

正确的选择实际上取决于您的需求。

于 2013-03-04T09:49:18.780 回答
0

您必须授予 dba 权限才能从您的用户连接到 KARUMA 用户或 CONNECT 权限。

请点击此链接 http://docs.oracle.com/cd/B28359_01/java.111/b31224/proxya.htm

于 2013-03-10T09:04:21.347 回答