Here is an example that behaves like the
generate_unique() function of DB2:
CREATE FUNCTION GENERATE_UNIQUE()
RETURNS CHAR(13) FOR BIT DATA PARAMETER STYLE JAVA NO
SQL LANGUAGE JAVA
EXTERNAL NAME 'com.mycompany.MyClass.generate_unique';
Here is the corresponding java function in MyClass:
static public byte[] generate_unique()throws
SQLException{
return ... // generate and return a byte[13];
}
Regards,
Ali
--- Bernd Ruehlicke <[EMAIL PROTECTED]> wrote:
> Hi there,
>
> still Derby newby which is digging through the
> documentatins but cannot
> find wht he needs ...
>
> trying to make a dum funtion MYFUNC without any
> parameters returning a
> number it gets via soem sql lookups. Any examples
> out there of how a
> function is to be declared without parameters and
> how the java program
> can do SQL against Derby ? So that I can use this
> function like
>
> ij> values myfunc;
>
>
> For the declaration I tried:
> CREATE FUNCTION MYFUNC RETURNS BIGINT PARAMETER
> STYLE JAVA CONTAINS SQL
> LANGUAGE JAVA EXTERNAL NAME
> 'com.xyz.DerbyFunctions.myfunc'
>
> and got
> ij> CREATE FUNCTION TEST1 RETURNS BIGINT PARAMETER
> STYLE JAVA CONTAINS
> SQL LANGUAGE JAVA EXTERNAL NAME
> 'com.xyz.DerbyFunctions.myfunc'; ERROR
> 42X01: Syntax error: Encountered "RETURNS" at line
> 1, column 23.
>
>
> So QUESTION:
>
> 1) How to make this CREATE FUNC call correctly ?
> 2) Is it possible to make a function so I do not
> need to add () for no
> parameters
> 3) How to I do SQL against Derby in my Java static
> method ?!?!
>
> Thanx
> B-)
>
>
>
>