User defined functions that support *all* (or multiple) data types are
not supported. Either ISNULL needs to be implemented as a "core"
function within H2, or you use IFNULL(..), NVL(..), COALESCE(...), or
CASE / CASEWHEN.
Does Sybase support IFNULL or CASE?
Regards,
Thomas
> --
> You received this message because you are subscribed to the Google Groups "H2 Database" group.
> To post to this group, send email to h2-da...@googlegroups.com.
> To unsubscribe from this group, send email to h2-database...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/h2-database?hl=en.
>
>
I understand. Is it possible for you to use IFNULL? According to this
document, Sybase Adaptive Server IQ supports it:
http://manuals.sybase.com/onlinebooks/group-iq/iqg1250e/iqref/@Generic__BookTextView/34146;pt=34859
> note: multiple evaluations of 'sum' when sum(..) != null
In my experience, calculating the sum twice isn't a big overhead. The
bottleneck is usually reading from disk. In theory, the duplicate
'sum' could be optimized in the database engine (H2 doesn't do that
however).
Regards,
Thomas
> Any alternative as use Comparable types?
>
> public static Comparable isNull(Comparable value, Comparable defaultValue) {
No. Currently you would need to use a function with the correct data
type. You could overload it, that means one function for each required
data type, but that's a lot of work.
Regards,
Thomas
> Caused by: org.h2.jdbc.JdbcSQLException: Matching Java methods must
> have different parameter counts:
> why?
H2 currently doesn't support overloading methods with the same name
and same parameter count. Supporting this would be possible, but quite
complicated. Do you know if other databases support it?
> I found another "incompatible" function: convert()
> Any solution?
No, I'm sorry. Probably the best solution is to add a Sybase
compatibility mode where parameters are swapped. I'm currently not
working on this, but patches are welcome of course!
Regards,
Thomas
> Any instruction or example code to start is welcome...
I think it's not hard to support those features. If you want to add
Sybase support, you first need to get familiar with the source code.
See http://www.h2database.com/html/build.html
Compatibility modes are here: Mode.java - just add one for Sybase.
"CONVERT" is here: Parser.java (search for "Function.CONVERT") and
Function.java (search for "case CONVERT:").
Regards,
Thomas