Search code examples
javaoracle-databasecallable-statement

Passing 'select from dual' as parameter to java callable statement


I am trying to pass SELECT FROM DUAL as parameter to callable statement in java as in example:

{?=call function1( ?, (select function2(?) from dual), ?)}

When I call this function I get exception: ORA-06550: line 1, column 165: PLS-00103: Encountered the symbol "SELECT" when expecting one of the following: ( - + case mod new not null others...

When I call function as {?=call function1( ?, ?, ?)}, it works fine, but I need to call another function as a parameter (password encryption for example).

Is there a way to call one function as parameter to another function?


Solution

  • How about

    BEGIN function1( ?,function2(?), ?) END;
    

    or

    {?=call function1( ?, function2(?), ?)}
    

    You don't need to call dual. Just in case, you can always use PL/SQL itself. Easy to to use and maintain.

    Oracle Docs

    Returning data from anonymous PL/SQL block - contains some useful code snippets on PL/SQL usage in JDBC.