Sorry, i have solved it :
INIT=create schema if not exists test\;runscript from
'classpath:scripts/schema.sql
in which i i put :
drop alias if exists TO_DATE;
create alias TO_DATE as $$
java.util.Date toDate(String s, String format) throws Exception {
return new java.text.SimpleDateFormat("yyyy-MM-dd
hh:mm:ss.sss").parse(s);
}
$$;
you must have 2 parameters in java function as well.
+
среда, 21 марта 2012 г. 14:39:39 UTC+1 пользователь ZPavel написал:
>
> Hi,
> How can i use this sql adding TO_DATE with spring?
> Thanks
>
> вторник, 22 ноября 2011 г. 20:20:35 UTC+1 пользователь Thomas Mueller
> написал:
>>
>> Hi,
>>
>> Even though our code runs fine, there are still some functions missing
>>> which are used in customization, e.g. 'Function "TO_DATE" not found' .
>>>
>>
>> There is a sample implementation in org/h2/test/todo/tools.sql:
>>
>> -- TO_DATE
>> create alias TO_DATE as $$
>> java.util.Date toDate(String s) throws Exception {
>> return new java.text.SimpleDateFormat("yyyy.MM.dd").parse(s);
>> }
>> $$;
>>
>> -- TO_CHAR
>> drop alias if exists TO_CHAR;
>> create alias TO_CHAR as $$
>> String toChar(BigDecimal x, String pattern) throws Exception {
>> return new java.text.DecimalFormat(pattern).format(x);
>> }
>>
>>> For using H2 as drop-in replacement we would like to add those Oracle
>>> specific functions when running in Oracle mode. Maybe we could create
>>> an add-on jar for this.
>>>
>>
>> Yes, I also thought about such a feature. Currently there is no such
>> 'plug' feature, but it does make sense to add it.
>>
>> What about a class that is loaded depending on the mode, and initializes
>> the functions. For example, a class org.h2.mode.Oracle with a static
>> init(Connection conn) method. This method is called when the Oracle mode is
>> enabled.
>>
>> 1. Who would like to join the effort of creating this drop-in
>>> replacement for Oracle ?
>>>
>>
>> My plan is not 100% compatibility (that would be extremely hard), but
>> better compatibility would be nice.
>>
>> 3. Is there already some a Wiki for H2 development ?
>>>
>>
>> Currently not. Let's see if this is required. I do like wikis, but
>> they quickly tend to be outdated and not maintained. I prefer to just
>> update the regular documentation instead.
>>
>> > What we can provide
>>
>> If it's OK for you to provide it as open source, then sure we can discuss
>> about that.
>>
>> Regards,
>> Thomas
>>
>>
--
You received this message because you are subscribed to the Google Groups "H2
Database" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/h2-database/-/2FgPIQOLAksJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/h2-database?hl=en.