I have a stored function in Oracle database pAdCampaign.fGetAlgoGroupKey. How to see the code of this function.?
Asked
Active
Viewed 1.9e+01k times
34
-
1is "pAdCampaign" the schema or a package? – DazzaL Jan 08 '13 at 10:03
-
possible duplicate of [.NET: How to retrieve the body of an Oracle 9i PL/SQL procedure or function](http://stackoverflow.com/questions/554115/net-how-to-retrieve-the-body-of-an-oracle-9i-pl-sql-procedure-or-function) – APC Jan 08 '13 at 12:59
3 Answers
53
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;

Shivam Puri
- 1,578
- 12
- 25

DazzaL
- 21,638
- 3
- 49
- 57
-
1If you're selecting from ALL_SOURCE you should include the OWNER in the WHERE clause. – APC Jan 08 '13 at 12:52
-
2
13
SELECT text
FROM all_source
where name = 'FGETALGOGROUPKEY'
order by line
alternatively:
select dbms_metadata.get_ddl('FUNCTION', 'FGETALGOGROUPKEY')
from dual;
-
For you first answer query it's giving an error ORA-00904: "PROCEDURENAME": invalid identifier. – Vallabh Patade Jan 08 '13 at 10:08
-
It's returning null. But I am sure this function is there/exist. I am calling this function from Java code or from SQL code it's returning the value as expected. – Vallabh Patade Jan 08 '13 at 10:13
-
@VallabhPatade Maybe you created it using double quotes, and the name is now case-sensitive? Are you connected with the user that owns the function? – Jan 08 '13 at 10:21
-
@VallabhPatade: just saw that you are actually talking about a package function, not a standalone function (which you should have mentioned right away). See DazzaL's answer then. – Jan 08 '13 at 10:22
-
1dbms_metadata.get_ddl only works for your own objects or for SYS, so the first solution sometimes returns text where the second doesn't. – Michael Grazebrook May 29 '18 at 17:08
2
You can also use DBMS_METADATA:
select dbms_metadata.get_ddl('FUNCTION', 'FGETALGOGROUPKEY', 'PADCAMPAIGN')
from dual

Frank Schmitt
- 30,195
- 12
- 73
- 107