Solved

Oracle - Get detail of a UDF

Posted on 2013-06-13
16
459 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
  • 9
  • 7
16 Comments
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
Comment Utility
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
Comment Utility
>>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
Comment Utility
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
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
Comment Utility
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
Comment Utility
select dbms_metadata.get_ddl ('FUNCTION','F_Count_Attempts') from dual;
0
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
Comment Utility
Make it upper case:

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

Author Comment

by:patriotpacer
Comment Utility
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
Comment Utility
Is it possible that I just can't see it?  Can call it but can't view contents?
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 76

Accepted Solution

by:
slightwv (䄆 Netminder) earned 500 total points
Comment Utility
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
Comment Utility
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 76

Expert Comment

by:slightwv (䄆 Netminder)
Comment Utility
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
Comment Utility
Cool.  

Last question...

Is there a way to find the owner?
0
 

Author Closing Comment

by:patriotpacer
Comment Utility
thanks for all the help.
0
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
Comment Utility
>>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
Comment Utility
>>select owner from all_objects where object_name='PKG_SCHEDULER';

Thanks, slightwv!
0
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
Comment Utility
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
Have you ever had to make fundamental changes to a table in Oracle, but haven't been able to get any downtime?  I'm talking things like: * Dropping columns * Shrinking allocated space * Removing chained blocks and restoring the PCTFREE * Re-or…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.

763 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now