Is there a way in oracle to see what a procedure's structure is? I'm trying to log and am running procedures and wanted to store the actual procedure structure in my log.
To view the definition a procedure in Object Explorer In Object Explorer, connect to an instance of Database Engine and then expand that instance. Expand Databases, expand the database in which the procedure belongs, and then expand Programmability.
The syntax to create a procedure in Oracle is: CREATE [OR REPLACE] PROCEDURE procedure_name [ (parameter [,parameter]) ] IS [declaration_section] BEGIN executable_section [EXCEPTION exception_section] END [procedure_name]; When you create a procedure or function, you may define parameters.
A stored procedure is a prepared SQL code that you can save, so the code can be reused over and over again. So if you have an SQL query that you write over and over again, save it as a stored procedure, and then just call it to execute it.
You could query the ALL_SOURCE
table
SELECT text
FROM all_source
WHERE owner = <<owner of procedure>>
AND name = <<name of procedure>>
ORDER BY line
If you are dealing with a procedure that is inside a package
SELECT text
FROM all_source
WHERE owner = <<owner of procedure>>
AND name = <<name of procedure>>
AND type = 'PACKAGE BODY'
ORDER BY line
will give you the text of the package body. You could also get the text of the package specification using a TYPE
of "PACKAGE"
SELECT TEXT, LINE FROM ALL_SOURCE WHERE
NAME = UPPER('$name') -- the table also has an owner field to track the user
ORDER BY TYPE, -- type is generally procedure, but there are functions and
-- more complex structures as well, such as PACKAGE
TO_NUMBER( LINE )
dbms_metadata package, get_ddl function, perhaps?
SELECT dbms_metadata.get_ddl('PROCEDURE','<yourproc>','<schema>') FROM dual;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With