You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-user@db.apache.org by Mike Norman <mw...@gmail.com> on 2007/09/06 15:59:02 UTC

cannot create a function with no arguments

latest Derby:
  Apache Derby
  10.3.1.4 - (561794)
  Apache Derby Network Client JDBC Driver
  10.1.2.1

I have an extremely simple helper class:

  package test;

  import java.sql.SQLException;

  public class SPHelper {

      public static void ProcNoArgs() throws SQLException {
      }
    
      public static String FuncNoArgs() throws SQLException {
          return "gidday";
      }
  }

The first external procedure works:

  CREATE PROCEDURE PROC_NO_ARGS() 
  LANGUAGE JAVA 
  EXTERNAL NAME 'test.SPHelper.ProcNoArgs' 
  PARAMETER STYLE JAVA
  NO SQL

but I cannot create a no-arg function:

  CREATE FUNCTION FUNC_NO_ARGS() RETURNS VARCHAR
  LANGUAGE JAVA
  EXTERNAL NAME 'test.SPHelper.FuncNoArgs'
  PARAMETER STYLE JAVA
  NO SQL
  CALLED ON NULL INPUT

I get the following exception:

 09:43:30  [CREATE - 0 row(s), 0.000 secs]  [Error Code: -1, SQL State:
42X01]  Syntax error: Encountered "LANGUAGE" at line 2, column 3.
... 1 statement(s) executed, 0 row(s) affected, exec/fetch time: 0.000/0.000
sec [0 successful, 0 warnings, 1 errors]

Any ideas?


-- 
View this message in context: http://www.nabble.com/cannot-create-a-function-with-no-arguments-tf4392364.html#a12523237
Sent from the Apache Derby Users mailing list archive at Nabble.com.


Re: cannot create a function with no arguments

Posted by Mike Norman <mw...@gmail.com>.
that did it - thanks!


Hi  Mike,

I think the problem is the datatype of the function's return value. The 
VARCHAR datatype needs a length. This should work:

CREATE FUNCTION FUNC_NO_ARGS() RETURNS VARCHAR( 100 )
...

Hope this helps,
-Rick


-- 
View this message in context: http://www.nabble.com/cannot-create-a-function-with-no-arguments-tf4392364.html#a12524824
Sent from the Apache Derby Users mailing list archive at Nabble.com.


Re: cannot create a function with no arguments

Posted by Rick Hillegas <Ri...@Sun.COM>.
Hi  Mike,

I think the problem is the datatype of the function's return value. The 
VARCHAR datatype needs a length. This should work:

CREATE FUNCTION FUNC_NO_ARGS() RETURNS VARCHAR( 100 )
...

Hope this helps,
-Rick



Mike Norman wrote:
> latest Derby:
>   Apache Derby
>   10.3.1.4 - (561794)
>   Apache Derby Network Client JDBC Driver
>   10.1.2.1
>
> I have an extremely simple helper class:
>
>   package test;
>
>   import java.sql.SQLException;
>
>   public class SPHelper {
>
>       public static void ProcNoArgs() throws SQLException {
>       }
>     
>       public static String FuncNoArgs() throws SQLException {
>           return "gidday";
>       }
>   }
>
> The first external procedure works:
>
>   CREATE PROCEDURE PROC_NO_ARGS() 
>   LANGUAGE JAVA 
>   EXTERNAL NAME 'test.SPHelper.ProcNoArgs' 
>   PARAMETER STYLE JAVA
>   NO SQL
>
> but I cannot create a no-arg function:
>
>   CREATE FUNCTION FUNC_NO_ARGS() RETURNS VARCHAR
>   LANGUAGE JAVA
>   EXTERNAL NAME 'test.SPHelper.FuncNoArgs'
>   PARAMETER STYLE JAVA
>   NO SQL
>   CALLED ON NULL INPUT
>
> I get the following exception:
>
>  09:43:30  [CREATE - 0 row(s), 0.000 secs]  [Error Code: -1, SQL State:
> 42X01]  Syntax error: Encountered "LANGUAGE" at line 2, column 3.
> ... 1 statement(s) executed, 0 row(s) affected, exec/fetch time: 0.000/0.000
> sec [0 successful, 0 warnings, 1 errors]
>
> Any ideas?
>
>
>