Oracle通过shell脚本查看package的信息(2)

PROC_OWNER=`sqlplus -silent $DB_CONN_STR@$SH_DB_SID <<END
 set pagesize 40 feedback off verify off heading on echo off
 col owner format a20
 col object_name format a30
 col subobject_name format a10
 set linesize 150
 break on object_name
 select object_name,owner,subobject_name,object_type,object_id, created,last_ddl_time,status from dba_objects where object_type like 'PACKAGE%' and object_name=upper('$2') and owner=upper('$1')
 ORDER BY OBJECT_ID
 /
 exit;
 END`

if [ -z "$PROC_OWNER" ]; then
  echo "no object exists, please check again"
  exit 0
 else
  echo '*******************************************'
  echo " $PROC_OWNER    "
  echo '*******************************************'
 fi


 sqlplus -silent $DB_CONN_STR@$SH_DB_SID <<EOF
 prompt .
 set long 99999
 set pages 0
 select text
 from dba_source
 where type in ('PACKAGE BODY','PACKAGE') and name=upper('$2') and owner=upper('$1')
 order by type, line;

EOF
 exit


脚本运行情况如下:
[ora11g@rac1 dbm_lite]$ ksh showpack.sh sys DBMS_METADATA_UTIL|less
 *******************************************
 
 OBJECT_NAME                    OWNER                SUBOBJECT_ OBJECT_TYPE          OBJECT_ID CREATED  LAST_DDL_ STATUS
 ------------------------------ -------------------- ---------- ------------------- ---------- --------- --------- -------
 DBMS_METADATA_UTIL            SYS                            PACKAGE                  9681 23-JAN-14 23-JAN-14 VALID
                                SYS                            PACKAGE BODY            11983 23-JAN-14 23-JAN-14 VALID   
 *******************************************
 .
 PACKAGE dbms_metadata_util AUTHID DEFINER AS
 ------------------------------------------------------------
 -- Overview
 -- This pkg implements utility functions of the mdAPI.
 ---------------------------------------------------------------------
 -- SECURITY
 -- This package is owned by SYS. It runs with definers, not invokers rights
 -- because it needs to access dictionary tables.

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/6e40c21935a533bff668f058ffd97ebc.html