[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Oracle - Get detail of a UDF

Posted on 2013-06-13
16
Medium Priority
?
489 Views
Last Modified: 2013-06-13
I'm needing to see the contents of a particular user defined function in Oracle.

How do I get the detail?  I'm using Toad.
0
Comment
Question by:patriotpacer
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 7
16 Comments
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 39244231
Try this:
select dbms_metadata.get_ddl('FUNCTION','THE_UDF_NAME') from dual;


Using Toad, you should be able to browse to the object to see the code but I'm not a Toad user so I don't know for sure.
0
 

Author Comment

by:patriotpacer
ID: 39244236
>>Using Toad, you should be able to browse to the object to see the code but I'm not a Toad user so I don't know for sure.

I'm more sql server, so don't know my way around Toad very well.

Thx...let me try your tip.
0
 

Author Comment

by:patriotpacer
ID: 39244249
Any tips on getting past this error?



ORA-31603: object "F_Count_Attempts" of type FUNCTION not found in schema "<<my username>>"
ORA-06512: at "SYS.DBMS_METADATA", line 5088
ORA-06512: at "SYS.DBMS_METADATA", line 7589
ORA-06512: at line 1
0
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 39244258
Did you add the double quotes?

Oracle converts object names to upper case.  You can force case sensitivity by using double quotes but it is not advised.

If you used mixed-case with single quotes, make it all upper case inside the single quotes.

Can you post the exact select you ran?
0
 

Author Comment

by:patriotpacer
ID: 39244262
select dbms_metadata.get_ddl ('FUNCTION','F_Count_Attempts') from dual;
0
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 39244275
Make it upper case:

select dbms_metadata.get_ddl ('FUNCTION','F_COUNT_ATTEMPTS') from dual;
0
 

Author Comment

by:patriotpacer
ID: 39244292
Still same error.  

Here's how it's used:
...Pkg_Scheduler.F_Count_Attempts(i.ID)...

Open in new window

0
 

Author Comment

by:patriotpacer
ID: 39244301
Is it possible that I just can't see it?  Can call it but can't view contents?
0
 
LVL 77

Accepted Solution

by:
slightwv (䄆 Netminder) earned 2000 total points
ID: 39244302
It doesn't matter how it's called.  Oracle still converts it to upper case.

This way all these work (assuming you have a table named bob)
select * from BOB;
select * from BoB;
select * from bob;



>>Pkg_Scheduler.F_Count_Attempts

OK, this is part of a package.  This is different.

select dbms_metadata.get_ddl ('PACKAGE_BODY','PKG_SCHEDULER') from dual;
0
 

Author Comment

by:patriotpacer
ID: 39244335
Here's what I get...

ORA-31603: object "PKG_SCHEDULER" of type PACKAGE_BODY not found in schema "<<my username>>"
ORA-06512: at "SYS.DBMS_METADATA", line 5088
ORA-06512: at "SYS.DBMS_METADATA", line 7589
ORA-06512: at line 1
0
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 39244344
You may not have permission to see the source.

You can add the owner to the call:
select dbms_metadata.get_ddl ('PACKAGE_BODY','PKG_SCHEDULER','SCOTT') from dual;

Where SCOTT is the owning user.
0
 

Author Comment

by:patriotpacer
ID: 39244356
Cool.  

Last question...

Is there a way to find the owner?
0
 

Author Closing Comment

by:patriotpacer
ID: 39244373
thanks for all the help.
0
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 39244377
>>Is there a way to find the owner?

Try this:
select owner from all_objects where object_name='PKG_SCHEDULER';
0
 

Author Comment

by:patriotpacer
ID: 39244380
>>select owner from all_objects where object_name='PKG_SCHEDULER';

Thanks, slightwv!
0
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 39244428
No problem.

Welcome to Oracle!

Once you get over the culture shock and learn your way around, you'll never want to go back to SQL Server!!!
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
Via a live example, show how to take different types of Oracle backups using RMAN.

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question