Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Java classes
kuassi.mensah_at_gmail.com wrote:
> Vladimir M. Zakharychev wrote:
> >> Hmm... Have you tried this query yourself? ;)
>
> Yes indeed, see the query and the return in section 2.1.9 in my book
> fwiw, here is the script for creating the java class
>
Well, it probably gives expected output thanks to "dbms_java.shortname(object_name) like ..." predicate. What initially bothered me is that "object_type not in (...)" predicate. There are lot more object types than those listed that are not Java, calling dbms_java.shortname() on them is simply a waste. All Java objects in Oracle have 'JAVA' in their type name, so I thought "like 'JAVA%'" is a better filter. Also, if the 'LongNameSample' part is really long (longer than 20 characters), a few trailing characters of it may be eaten away and the LIKE will not find it. Using dbms_java.longname() and comparing it to the full class name seems more appropriate in this case:
SQL> CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED
VeryLongNameSample90123456789 AS
2 package longnamepkg.subpackage.foo;
3 class VeryLongNameSample90123456789 {
4 public static void main (String argv[]) {
5 System.out.println ("Hello LongNameSample");
6 }
7 }
8 /
Java created.
SQL> col DBMS_JAVA.SHORTNAME(OBJECT_NAME) format a40
SQL> select dbms_java.shortname(object_name), object_type, status
2 from user_objects
3 where object_type not in ('TABLE', 'VIEW', 'INDEX')
4 and dbms_java.shortname(object_name) like
'%VeryLongNameSample90123456789'
5 order by dbms_java.shortname(object_name);
no rows selected
SQL> col java_short_name format a30
SQL> select
2 dbms_java.shortname(object_name) java_short_name
3 ,object_type
4 ,status
5 from user_objects
6 where object_type like 'JAVA%'
7 and dbms_java.LONGNAME(object_name) =
'longnamepkg/subpackage/foo/VeryLongNameSample90123456789'
8 /
JAVA_SHORT_NAME OBJECT_TYPE STATUS ------------------------------ ------------------ ------- /92243f07_VeryLongNameSample90 JAVA CLASS VALID
Alternatively, one can use USER_JAVA_CLASSES view to see full information about all Java classes visible to the user. With this view, calls to dbms_java are unnecessary since NAME column shows full name of the class already.
Regards,
Vladimir M. Zakharychev
N-Networks, makers of Dynamic PSP(tm)
http://www.dynamicpsp.com
Received on Wed Dec 06 2006 - 00:38:53 CST
![]() |
![]() |