It was fairly easy, indeed. Just added another function with the same
function ID. Here's the patch. I didn't find any test case for
TRUNCATE, which I could've enhanced. I successfully checked this query
in the H2 Console, though.

select trunc(23.45, -1), truncate(23.45, -1), trunc(23.45, 1),
truncate(23.45, 1)

Cheers
Lukas

2012/4/21 Noel Grandin <[email protected]>:
> My apologies, you are correct.
>
> Care to have a bash at implementing this?
> The parsing code is really easy to work with, straightforward
> recursive-descent parser.
> Just search for "TRUNCATE" and and start with making "TRUNC" an alias.
>
>
> On Fri, Apr 20, 2012 at 15:27, Lukas Eder <[email protected]> wrote:
>> Hmm, not sure what you mean by "table modification method". You mean
>> the TRUNCATE statement?
>>
>> I didn't find any TRUNC() function in H2:
>> http://www.h2database.com/html/functions.html#trunc
>>
>> Only TRUNCATE() (on numbers, not dates):
>> http://www.h2database.com/html/functions.html#truncate
>>
>> So actually, yes, it would be lovely if TRUNC() / TRUNCATE() also
>> supported truncating dates, the way Oracle does, for instance :-)
>>
>> 2012/4/20 Noel Grandin <[email protected]>:
>>> TRUNC() is a scalar function that operates on values like dates.
>>> TRUNCATE is table modification method.
>>> They have nothing to do with each other besides the naming similarity.
>>>
>>> But yes, it would be nice to support it.
>>> Patches are welcome.
>>>
>>> On 2012-04-20 15:15, Lukas Eder wrote:
>>>>
>>>> Hello,
>>>>
>>>> This is a minor issue. I've found that many other databases support TRUNC
>>>> and TRUNCATE equally. H2 only has TRUNCATE:
>>>> http://www.h2database.com/html/functions.html#truncate
>>>>
>>>> Adding TRUNC() as an alias/synonym might be useful for increased
>>>> compatibility with
>>>>
>>>> - CUBRID
>>>> - DB2
>>>> - HSQLDB
>>>> - Ingres
>>>> - Oracle
>>>> - Postgres
>>>>
>>>> Cheers
>>>> Lukas
>>>> --
>>>> 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/-/FOkozo4knkAJ.
>>>> 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.

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
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.

Attachment: trunc.patch
Description: Binary data

Reply via email to