Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dump the body of a function or procedure in sqlplus

How can I dump out the body of a function or a procedure when using sqlplus to connect to an oracle database?

like image 725
David Oneill Avatar asked Dec 11 '09 21:12

David Oneill


People also ask

How do I export data from SQLPlus?

Oracle SQLPlus Export To CSV Using SPOOL Command SQLPlus is an interface to query the data present in Oracle DB. It is available in the form of a command-line tool and a Windows-based GUI tool. The SPOOL command will be used to perform Oracle SQLPlus export to CSV data.

What means @@ in SQLPlus?

@@ (double at sign) Runs a script. This command is similar to the @ (at sign) command It is useful for running nested scripts because it looks for the specified script in the same path as the calling script. / (slash) Executes the SQL command or PL/SQL block.

Can we return values from procedure?

A stored procedure does not have a return value but can optionally take input, output, or input-output parameters. A stored procedure can return output through any output or input-output parameter.

How do I run a procedure in SQLPlus?

To run a stored procedure in SQLPlus the command is something like this. SQL> EXECUTE procedure_name('passed_value');


2 Answers

select
    text
from
    user_source
where
    type = 'PROCEDURE'
and
    name='YOURPROCEDURENAME'
order by
    line;
like image 100
dacracot Avatar answered Sep 24 '22 07:09

dacracot


Use:

SELECT us.name,
       us.type,
       us.text
  FROM USER_SOURCE us
 WHERE us.type IN ('PROCEDURE', 'FUNCTION')
ORDER BY name, line
like image 41
OMG Ponies Avatar answered Sep 23 '22 07:09

OMG Ponies