web-dev-qa-db-ja.com

パッケージOracle内のすべての手順のリストを取得する方法

パッケージ内のすべての関数の名前を取得できますか。パッケージPKG_OWAがあり、パッケージ内のすべての手順をリストしたいとします。

22
शेखर

データディクショナリビューALL_PROCEDURES(またはパッケージだけが必要な場合はUSER_PROCEDURES)。 詳細をご覧ください

 select procedure_name
 from all_procedures
 where owner = 'YOU'
 and object_name = 'YOUR_PACKAGE'

これは、パッケージ仕様で公開されているパブリックプロシージャの一覧です。ソーステキストを処理する以外に、プライベートプロシージャ(つまり、パッケージ本体でのみ指定されたプロシージャ)を取得する簡単な方法はありません。 Oracleは、この情報を収集するために使用できるユーティリティPL/SCOPEを提供していますが、セッション設定を変更してコードを再コンパイルする必要があるため、すべての状況に適しているとは限りません。 詳細を検索

39
APC

誰かに役立つかもしれませんが、これはパッケージ本体でのみ指定されたプロシージャと関数を見つける方法です。

select name, 
       type,
       decode(usage,'DECLARATION', 'body only', 'DEFINITION', 'spec and body', usage) defined_on,
       line body_line
  from user_identifiers ui
  where type in ('PROCEDURE', 'FUNCTION')
  and usage_context_id = (select usage_id
    from user_identifiers
      where object_name = ui.object_name
        and object_type = ui.object_type
        and usage_context_id = 0)
  and object_name = 'your package name'
  and object_type = 'PACKAGE BODY'
  order by name
7

APCからの答えは正しい行にありますが、指定されたSQLは 'YOU'が所有するプロシージャのみをリストし、USER_PROCEDURESから選択するのと同じですが、他のスキーマにパッケージがある可能性があります

SQL> select * from all_procedures where owner='TEST';

OWNER                          OBJECT_NAME
------------------------------ ------------------------------
PROCEDURE_NAME                 AGG PIP IMPLTYPEOWNER
------------------------------ --- --- ------------------------------
IMPLTYPENAME                   PAR INT DET AUTHID
------------------------------ --- --- --- ------------
TEST                           TEST
                               NO  NO
                               NO  NO  NO  DEFINER

SQL> select * from user_procedures;

OBJECT_NAME                    PROCEDURE_NAME                 AGG PIP
------------------------------ ------------------------------ --- ---
IMPLTYPEOWNER                  IMPLTYPENAME                   PAR INT DET
 ------------------------------ ------------------------------ --- --- ---
AUTHID
------------
TEST                                                          NO  NO
                                                          NO  NO  NO

また、パッケージ、プロシージャ、または関数の実行を許可および取り消すと、DBA_TAB_PRIVSテーブルに表示されることに注意してください(テーブルの挿入/更新/削除特権と同じテーブル)

Oracleが提供するDBMSパッケージなどのパッケージの名前を取得したら、予想されるパラメーターとタイプのリストを提供するDESCを使用することもできます。

SQL> desc dbms_lob
PROCEDURE APPEND
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 DEST_LOB                       BLOB                    IN/OUT
 SRC_LOB                        BLOB                    IN
PROCEDURE APPEND
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 DEST_LOB                       CLOB                    IN/OUT
 SRC_LOB                        CLOB                    IN
PROCEDURE CLOSE
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 LOB_LOC                        BLOB                    IN/OUT
PROCEDURE CLOSE
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 LOB_LOC                        CLOB                    IN/OUT
PROCEDURE CLOSE
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 FILE_LOC                       BINARY FILE LOB         IN/OUT
FUNCTION COMPARE RETURNS NUMBER(38)
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 LOB_1                          BLOB                    IN
 LOB_2                          BLOB                    IN
 AMOUNT                         NUMBER(38)              IN     DEFAULT
 OFFSET_1                       NUMBER(38)              IN     DEFAULT
 OFFSET_2                       NUMBER(38)              IN     DEFAULT
FUNCTION COMPARE RETURNS NUMBER(38)
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 LOB_1                          CLOB                    IN
 LOB_2                          CLOB                    IN
 AMOUNT                         NUMBER(38)              IN     DEFAULT
 OFFSET_1                       NUMBER(38)              IN     DEFAULT
 OFFSET_2                       NUMBER(38)              IN     DEFAULT
FUNCTION COMPARE RETURNS NUMBER(38)
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 FILE_1                         BINARY FILE LOB         IN
 FILE_2                         BINARY FILE LOB         IN
 AMOUNT                         NUMBER(38)              IN
 OFFSET_1                       NUMBER(38)              IN     DEFAULT
 OFFSET_2                       NUMBER(38)              IN     DEFAULT
PROCEDURE CONVERTTOBLOB
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 DEST_LOB                       BLOB                    IN/OUT
 SRC_CLOB                       CLOB                    IN
 AMOUNT                         NUMBER(38)              IN
 DEST_OFFSET                    NUMBER(38)              IN/OUT
 SRC_OFFSET                     NUMBER(38)              IN/OUT
 BLOB_CSID                      NUMBER                  IN
 LANG_CONTEXT                   NUMBER(38)              IN/OUT
 WARNING                        NUMBER(38)              OUT
PROCEDURE CONVERTTOCLOB
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 DEST_LOB                       CLOB                    IN/OUT
 SRC_BLOB                       BLOB                    IN
 AMOUNT                         NUMBER(38)              IN
 DEST_OFFSET                    NUMBER(38)              IN/OUT
 SRC_OFFSET                     NUMBER(38)              IN/OUT
 BLOB_CSID                      NUMBER                  IN
 LANG_CONTEXT                   NUMBER(38)              IN/OUT
 WARNING                        NUMBER(38)              OUT
PROCEDURE COPY
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 DEST_LOB                       BLOB                    IN/OUT
 SRC_LOB                        BLOB                    IN
 AMOUNT                         NUMBER(38)              IN
 DEST_OFFSET                    NUMBER(38)              IN     DEFAULT
 SRC_OFFSET                     NUMBER(38)              IN     DEFAULT
PROCEDURE COPY
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 DEST_LOB                       CLOB                    IN/OUT
 SRC_LOB                        CLOB                    IN
 AMOUNT                         NUMBER(38)              IN
 DEST_OFFSET                    NUMBER(38)              IN     DEFAULT
 SRC_OFFSET                     NUMBER(38)              IN     DEFAULT
PROCEDURE CREATETEMPORARY
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 LOB_LOC                        BLOB                    IN/OUT
 CACHE                          BOOLEAN                 IN
 DUR                            BINARY_INTEGER          IN     DEFAULT
PROCEDURE CREATETEMPORARY
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 LOB_LOC                        CLOB                    IN/OUT
 CACHE                          BOOLEAN                 IN
 DUR                            BINARY_INTEGER          IN     DEFAULT
PROCEDURE ERASE
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 LOB_LOC                        BLOB                    IN/OUT
 AMOUNT                         NUMBER(38)              IN/OUT
 OFFSET                         NUMBER(38)              IN     DEFAULT
PROCEDURE ERASE
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 LOB_LOC                        CLOB                    IN/OUT
 AMOUNT                         NUMBER(38)              IN/OUT
 OFFSET                         NUMBER(38)              IN     DEFAULT
PROCEDURE FILECLOSE
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 FILE_LOC                       BINARY FILE LOB         IN/OUT
PROCEDURE FILECLOSEALL
FUNCTION FILEEXISTS RETURNS NUMBER(38)
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 FILE_LOC                       BINARY FILE LOB         IN
PROCEDURE FILEGETNAME
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 FILE_LOC                       BINARY FILE LOB         IN
 DIR_ALIAS                      VARCHAR2                OUT
 FILENAME                       VARCHAR2                OUT
FUNCTION FILEISOPEN RETURNS NUMBER(38)
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 FILE_LOC                       BINARY FILE LOB         IN
PROCEDURE FILEOPEN
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 FILE_LOC                       BINARY FILE LOB         IN/OUT
 OPEN_MODE                      BINARY_INTEGER          IN     DEFAULT
PROCEDURE FREETEMPORARY
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 LOB_LOC                        BLOB                    IN/OUT
PROCEDURE FREETEMPORARY
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 LOB_LOC                        CLOB                    IN/OUT
FUNCTION GETCHUNKSIZE RETURNS NUMBER(38)
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 LOB_LOC                        BLOB                    IN
FUNCTION GETCHUNKSIZE RETURNS NUMBER(38)
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 LOB_LOC                        CLOB                    IN
FUNCTION GETLENGTH RETURNS NUMBER(38)
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 LOB_LOC                        BLOB                    IN
FUNCTION GETLENGTH RETURNS NUMBER(38)
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 LOB_LOC                        CLOB                    IN
FUNCTION GETLENGTH RETURNS NUMBER(38)
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 FILE_LOC                       BINARY FILE LOB         IN
FUNCTION GET_STORAGE_LIMIT RETURNS NUMBER(38)
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 LOB_LOC                        CLOB                    IN
FUNCTION GET_STORAGE_LIMIT RETURNS NUMBER(38)
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 LOB_LOC                        BLOB                    IN
FUNCTION INSTR RETURNS NUMBER(38)
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 LOB_LOC                        BLOB                    IN
 PATTERN                        RAW                     IN
 OFFSET                         NUMBER(38)              IN     DEFAULT
 NTH                            NUMBER(38)              IN     DEFAULT
FUNCTION INSTR RETURNS NUMBER(38)
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 LOB_LOC                        CLOB                    IN
 PATTERN                        VARCHAR2                IN
 OFFSET                         NUMBER(38)              IN     DEFAULT
 NTH                            NUMBER(38)              IN     DEFAULT
FUNCTION INSTR RETURNS NUMBER(38)
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 FILE_LOC                       BINARY FILE LOB         IN
 PATTERN                        RAW                     IN
 OFFSET                         NUMBER(38)              IN     DEFAULT
 NTH                            NUMBER(38)              IN     DEFAULT
FUNCTION ISOPEN RETURNS NUMBER(38)
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 LOB_LOC                        BLOB                    IN
FUNCTION ISOPEN RETURNS NUMBER(38)
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 LOB_LOC                        CLOB                    IN
FUNCTION ISOPEN RETURNS NUMBER(38)
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 FILE_LOC                       BINARY FILE LOB         IN
FUNCTION ISTEMPORARY RETURNS NUMBER(38)
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 LOB_LOC                        BLOB                    IN
FUNCTION ISTEMPORARY RETURNS NUMBER(38)
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 LOB_LOC                        CLOB                    IN
PROCEDURE LOADBLOBFROMFILE
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 DEST_LOB                       BLOB                    IN/OUT
 SRC_BFILE                      BINARY FILE LOB         IN
 AMOUNT                         NUMBER(38)              IN
 DEST_OFFSET                    NUMBER(38)              IN/OUT
 SRC_OFFSET                     NUMBER(38)              IN/OUT
PROCEDURE LOADCLOBFROMFILE
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 DEST_LOB                       CLOB                    IN/OUT
 SRC_BFILE                      BINARY FILE LOB         IN
 AMOUNT                         NUMBER(38)              IN
 DEST_OFFSET                    NUMBER(38)              IN/OUT
 SRC_OFFSET                     NUMBER(38)              IN/OUT
 BFILE_CSID                     NUMBER                  IN
 LANG_CONTEXT                   NUMBER(38)              IN/OUT
 WARNING                        NUMBER(38)              OUT
PROCEDURE LOADFROMFILE
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 DEST_LOB                       BLOB                    IN/OUT
 SRC_LOB                        BINARY FILE LOB         IN
 AMOUNT                         NUMBER(38)              IN
 DEST_OFFSET                    NUMBER(38)              IN     DEFAULT
 SRC_OFFSET                     NUMBER(38)              IN     DEFAULT
PROCEDURE LOADFROMFILE
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 DEST_LOB                       CLOB                    IN/OUT
 SRC_LOB                        BINARY FILE LOB         IN
 AMOUNT                         NUMBER(38)              IN
 DEST_OFFSET                    NUMBER(38)              IN     DEFAULT
 SRC_OFFSET                     NUMBER(38)              IN     DEFAULT
PROCEDURE OPEN
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 LOB_LOC                        BLOB                    IN/OUT
 OPEN_MODE                      BINARY_INTEGER          IN
PROCEDURE OPEN
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 LOB_LOC                        CLOB                    IN/OUT
 OPEN_MODE                      BINARY_INTEGER          IN
PROCEDURE OPEN
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 FILE_LOC                       BINARY FILE LOB         IN/OUT
 OPEN_MODE                      BINARY_INTEGER          IN     DEFAULT
PROCEDURE READ
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 LOB_LOC                        BLOB                    IN
 AMOUNT                         NUMBER(38)              IN/OUT
 OFFSET                         NUMBER(38)              IN
 BUFFER                         RAW                     OUT
PROCEDURE READ
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 LOB_LOC                        CLOB                    IN
 AMOUNT                         NUMBER(38)              IN/OUT
 OFFSET                         NUMBER(38)              IN
 BUFFER                         VARCHAR2                OUT
PROCEDURE READ
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 FILE_LOC                       BINARY FILE LOB         IN
 AMOUNT                         NUMBER(38)              IN/OUT
 OFFSET                         NUMBER(38)              IN
 BUFFER                         RAW                     OUT
FUNCTION SUBSTR RETURNS RAW
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 LOB_LOC                        BLOB                    IN
 AMOUNT                         NUMBER(38)              IN     DEFAULT
 OFFSET                         NUMBER(38)              IN     DEFAULT
FUNCTION SUBSTR RETURNS VARCHAR2
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 LOB_LOC                        CLOB                    IN
 AMOUNT                         NUMBER(38)              IN     DEFAULT
 OFFSET                         NUMBER(38)              IN     DEFAULT
FUNCTION SUBSTR RETURNS RAW
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 FILE_LOC                       BINARY FILE LOB         IN
 AMOUNT                         NUMBER(38)              IN     DEFAULT
 OFFSET                         NUMBER(38)              IN     DEFAULT
PROCEDURE TRIM
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 LOB_LOC                        BLOB                    IN/OUT
 NEWLEN                         NUMBER(38)              IN
PROCEDURE TRIM
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 LOB_LOC                        CLOB                    IN/OUT
 NEWLEN                         NUMBER(38)              IN
PROCEDURE WRITE
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 LOB_LOC                        BLOB                    IN/OUT
 AMOUNT                         NUMBER(38)              IN
 OFFSET                         NUMBER(38)              IN
 BUFFER                         RAW                     IN
PROCEDURE WRITE
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 LOB_LOC                        CLOB                    IN/OUT
 AMOUNT                         NUMBER(38)              IN
 OFFSET                         NUMBER(38)              IN
 BUFFER                         VARCHAR2                IN
PROCEDURE WRITEAPPEND
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 LOB_LOC                        BLOB                    IN/OUT
 AMOUNT                         NUMBER(38)              IN
 BUFFER                         RAW                     IN
PROCEDURE WRITEAPPEND
 Argument Name                  Type                    In/Out Default?
 ------------------------------ ----------------------- ------ --------
 LOB_LOC                        CLOB                    IN/OUT
 AMOUNT                         NUMBER(38)              IN
 BUFFER                         VARCHAR2                IN
4
Trevor North

私はこれを使用します:

あなたのパッケージ:

SELECT *
FROM ALL_OBJECTS
WHERE OBJECT_TYPE = 'PACKAGE' 
    and owner = 'owner_name'
    and object_name = 'package_name'

あなたの手順(仕様からのみ、すなわちグローバル):

select *
 from all_procedures
 where owner = 'owner_name'
 and object_name = 'package_name'

プロシージャからのin/out引数:

select * 
from ALL_ARGUMENTS 
where owner = 'owner_name'
    and package_name = 'package_name'
    and object_name = 'procedure_name'

楽しい!

3
Andrey Khmelev