PLSQL包安装

时间:2014-01-31 15:32:06

标签: oracle plsql oracle11g

这里有人知道如何在Oracle 11g中安装PLSQL包吗?

我正在尝试使用这两个包:

  1. DBMS_NETWORK_ACL_ADMIN
  2. DBMS_NETWORK_ACL_UTILITY
  3. 我正在使用Oracle Application Express,到目前为止,SQL无法识别这些。

    谢谢。

1 个答案:

答案 0 :(得分:0)

为DBMS_NETWORK_ACL_ADMIN安装PLSQL包

您可以先检查它们是否存在,然后以用户sys:

运行它
select *
from   dba_objects
where  name = ...

如果它们不存在于Oracle RDBMS上(我不知道Express Express是否排除它们,但这看起来不合逻辑),那么您的数据库安装不好。最简单的方法是重新安装数据库。在这种情况下,您不需要更换软件,只需创建一个新数据库。

高级方法是重新安装部分数据字典。如果您以前从未这样做过,那么您可以认为数据库最终会损坏。您可以尝试执行实例?/dbs/catqm.sql。

替换?通过ORACLE_HOME所在的路径,然后是rdbms / admin。比如Linux上的$ ORACLE_HOME / rdbms / admin。请记住为其他用户关闭数据库。

维护ACL

额外的评论导致ACL缺失的结论。这是我用来在包中维护它们的方法。请注意,即使11.2.0.3有一个坏习惯,即使采取预防措施,也会经常使连接用户的会话崩溃。[/ p>

警告!此脚本允许访问1到32767之间的所有端口。您可能希望将此限制为适用于您的应用程序的端口。为了便于使用,我已将其粘贴到所有32K端口。

警告2! ACL的维护可能非常重要,并且可能导致安全风险(我们优雅地接受了Oracle的第11版:-)。如有疑问,请参与您的系统管理员或网络管理员。

--
-- When ORA-24247 errors continue despite creation of a network ACL,
-- first remove the ACL fully as user SYS using:
--
-- begin
--   dbms_network_acl_admin.drop_acl('/sys/acls/invantive-producer.xml');
-- end;
--
-- This occurs incidentally on Oracle 11g R1.
--
prompt Create Access Control Lists.

declare
  l_principal     varchar2(30) := upper('&&itgen_user_owner_login');
  l_acl           varchar2(300);
  l_acl_full_path varchar2(300);
  l_dummy         pls_integer;
  --
  -- To temporary disable this code, sometimes it causes installation
  -- issues.
  --
  l_skip_acl_maintenance boolean := false;
  --
  -- To temporarily disable granting the ACL access.
  --
  l_skip_acl_grants boolean := false;
begin
  l_acl := 'invantive-producer.xml';
  l_acl_full_path := '/sys/acls/' || l_acl;
  --
  if not l_skip_acl_maintenance
  then
    --
    -- Drop superfluous network ACLs for users and roles that no longer exist.
    --
    -- Dropping network ACLs is tricky. Queries on the view dba_network_acls
    -- often lead to ORA-600. This query seems to work reliable on Oracle 11g R1.
    --
    -- First delete all ACL privileges for which no ACL exists.
    -- During this, we will ignore problems.
    --
    for r in
    ( select nae.acl
      ,      nae.principal
      from   dba_network_acl_privileges nae
      where  nae.principal 
             not in 
             ( select usr.username 
               from   dba_users usr
               union all 
               select rle.role 
               from   dba_roles rle
             )
    )
    loop
      begin
        dbms_network_acl_admin.delete_privilege
        ( r.acl
        , r.principal
        );
        dbms_output.put_line('Dropped superfluous ACL ' || r.acl || '  for ' || r.principal || '.');
      exception
        when others
        then
          dbms_output.put_line('Ignoring error ' || sqlerrm);
      end;
    end loop;
    --
    -- Then try another time, not ignoring problems.
    --
    for r in
    ( select nae.acl
      ,      nae.principal
      from   dba_network_acl_privileges nae
      where  nae.principal 
             not in 
             ( select usr.username 
               from   dba_users usr
               union all 
               select rle.role 
               from   dba_roles rle
             )
    )
    loop
      dbms_network_acl_admin.delete_privilege
      ( r.acl
      , r.principal
      );
      dbms_output.put_line('Dropped superfluous ACL ' || r.acl || '  for ' || r.principal || '.');
    end loop;
    --
    -- Now create new network ACL when it does not yet exist.
    --
    begin
      select 1
      into   l_dummy
      from   resource_view rvw
      where  rvw.any_path = l_acl_full_path
      ;
      dbms_output.put_line('ACL ' || l_acl || ' already present. No action.');
    exception
      when no_data_found
      then
        dbms_network_acl_admin.create_acl
        ( acl             => l_acl
        , description     => 'Normal Access by Invantive Producer'
        , principal       => 'SYS'
        , is_grant        => true
        , privilege       => 'connect'
        , start_date      => null
        , end_date        => null
        );
        dbms_network_acl_admin.assign_acl
        ( acl        => l_acl
        , host       => '*'
        , lower_port => 1 /* ATTENTION! You may want to tighten this! */
        , upper_port => 32767 /* ATTENTION! You may want to tighten this! */
        );
        dbms_output.put_line('Created ACL ' || l_acl || ' for port 1 till 32767.');
    end;
  else
    dbms_output.put_line('Skipped maintenance of Access Control Lists.');
  end if;
  --
  if not l_skip_acl_grants
  then
    --
    -- Update the privilges for the ACL when not correct.
    --
    for r_usr
    in
    ( select l_principal principal
      from   dual
      union all
      --
      -- Any unspecified Invantive schema.
      --
      -- For SYS, itgen_schemas_r can contain multiple rows.
      --
      select sma_r.name principal
      from   itgen_schemas_r sma_r
    )
    loop
      begin
        select 1
        into   l_dummy
        from   dba_network_acl_privileges nae
        where  nae.acl        = l_acl_full_path
        and    nae.principal  = r_usr.principal
        and    nae.privilege  = 'connect'
        and    nae.is_grant   = 'true'
        and    nae.invert     = 'false'
        and    nae.start_date is null
        and    nae.end_date   is null
        ;
        dbms_output.put_line('Connect privileges already granted to ' || l_principal || '. No action.');
      exception
        when no_data_found
        then
          dbms_network_acl_admin.add_privilege
          ( acl         => l_acl
          , principal   => l_principal
          , is_grant    => true
          , privilege   => 'connect'
          , start_date  => null
          , end_date    => null
          );
          dbms_output.put_line('Connect privileges granted to ' || l_principal || '.');
      end;
    end loop;
    --
    commit;
  else
    dbms_output.put_line('Skipped grants of Access Control Lists.');
  end if;
end;
/