Is there a way of discovering which public constants are defined in a package header?

StackOverflow https://stackoverflow.com/questions/18357290

  •  25-06-2022
  •  | 
  •  

Pergunta

I'm trying to write a tool to unit-test a lot of Oracle procedures in packages which represent our API. The API procedures rely on package header constants, and to my knowledge there is no view which describes which of these are available. I've looked through the Oracle docs but haven't found anything relevant.

Is there a way of discovering which public constants are defined in a package header? SQL or PL/SQL is fine.

I imagine the answer is no, and that I'm going to have to come up with a wrapper function, like as described here, but I just thought I'd ask in case I was missing something clever.

Thanks.

Foi útil?

Solução

You can get the required information from the *_IDENTIFIERS static database views.

First, enable PL/Scope and recompile your packages, as per Is there any way to determine if a package has state in Oracle?

The following query returns the public constants and variables.

SELECT ui.object_name, 
       ui.name,
       ui.type
  FROM user_identifiers ui
 WHERE ui.object_type = 'PACKAGE'
  AND  ui.usage       = 'DECLARATION'
  AND  ui.type IN ('CONSTANT', 'VARIABLE')
ORDER BY ui.object_name, 
         ui.name
/
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top