Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to see PL/SQL Stored Function body in Oracle

Tags:

oracle

plsql

I have a stored function in Oracle database pAdCampaign.fGetAlgoGroupKey. How to see the code of this function.?

like image 865
Vallabh Patade Avatar asked Jan 08 '13 09:01

Vallabh Patade


People also ask

How do I view body functions in SQL Developer?

You should be able to see the pacakge body if you press the plus (+) button you had right at the name of your pacakge. If you don't see it, two things may be happening, you don't have the permissions (grants) on the user with which you are connected to the database session or the package body doesn't exist.

How do you view the code of a function in Oracle?

select text from all_source where name = 'PADCAMPAIGN' and type = 'PACKAGE BODY' order by line; Oracle doesn't store the source for a sub-program separately, so you need to look through the package source for it. If you're selecting from ALL_SOURCE you should include the OWNER in the WHERE clause.

What is stored function in PL SQL?

A stored function (also called a user function or user-defined function) is a set of PL/SQL statements you can call by name. Stored functions are very similar to procedures, except that a function returns a value to the environment in which it is called. User functions can be used as part of a SQL expression.


2 Answers

If is a package then you can get the source for that with:

    select text from all_source where name = 'PADCAMPAIGN'      and type = 'PACKAGE BODY'     order by line; 

Oracle doesn't store the source for a sub-program separately, so you need to look through the package source for it.

Note: I've assumed you didn't use double-quotes when creating that package, but if you did , then use

    select text from all_source where name = 'pAdCampaign'      and type = 'PACKAGE BODY'     order by line; 
like image 179
DazzaL Avatar answered Oct 14 '22 11:10

DazzaL


SELECT text  FROM all_source where name = 'FGETALGOGROUPKEY' order by line 

alternatively:

select dbms_metadata.get_ddl('FUNCTION', 'FGETALGOGROUPKEY') from dual; 
like image 20
a_horse_with_no_name Avatar answered Oct 14 '22 09:10

a_horse_with_no_name