This discussion is archived
4 Replies Latest reply: Dec 26, 2012 8:35 AM by Jim Smith RSS

How to use java.util.UUID in a function?

ceving Newbie
Currently Being Moderated
This works:

create or replace and compile
java source named "RandomUUID"
as
public class RandomUUID
{
public static String create()
{
return "123";
}
}

But this does not work:

create or replace and compile
java source named "RandomUUID"
as
public class RandomUUID
{
public static String create()
{
return java.util.UUID.randomUUID().toString();
}
}

Can anybody explain?

The log window shows the following strings:

oracle.dbtools.worksheet.commands.scriptrunner.task.ScriptRunnerTask
oracle.dbtools.raptor.newscriptrunner.PLSQL.reportWarning(PLSQL.java:261)

But I have no idea what this could mean.
  • 1. Re: How to use java.util.UUID in a function?
    Jim Smith Expert
    Currently Being Moderated
    This is the forum for Oracle's SQL Developer tool, not for general SQL and PL/SQL questions. Questions like this will get a better response in the SQL and PL/SQL forum, or a java forum.

    Incidentally, you need to be clearer on what "does not work" means. Does not compile? Doesn't run? Doesn't produce the expexted result.
  • 2. Re: How to use java.util.UUID in a function?
    ceving Newbie
    Currently Being Moderated
    My question is not a general PL/SQL question, because in general both code examples are correct as stated here: http://stackoverflow.com/a/13966531/402322

    This is a specific SQL Developer problem. The first problem is, that the compilation does not work and the second problem is, that the error message is unreadable.

    Not work means that the compiled code is flaged as invalid.

    Edited by: ceving on 25.12.2012 02:13
  • 3. Re: How to use java.util.UUID in a function?
    rp0428 Guru
    Currently Being Moderated
    >
    both code examples are correct as stated here: http://stackoverflow.com/a/13966531/402322

    This is a specific SQL Developer problem. The first problem is, that the compilation does not work and the second problem is, that the error message is unreadable.

    Not work means that the compiled code is flaged as invalid.
    >
    All of your code works for me in sql developer.

    And all of the code in the link answer you provided works also. The function returns a value just fine. No problems.
  • 4. Re: How to use java.util.UUID in a function?
    Jim Smith Expert
    Currently Being Moderated
    Both of these compile successfully for me in SQL Developer. Successful compilation shows an "Anonymous block completed" in the Script output pane.

    If I try on Oracle XE (which doesn't support java) the appropriate error message is displayed in the Script output pane.

    Where are you looking for messages?

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points