Hello Pay,
The current implementation of jOOQ's EXTRACT() function only implements
(parts) of what the SQL:2008 standard defines:
6.27 <numeric value function>
<extract expression> ::=
EXTRACT <left paren> <extract field> FROM <extract source> <right paren>
<extract field> ::=
<primary datetime field>
| <time zone field>
<primary datetime field> ::=
<non-second primary datetime field>
| SECOND
<non-second primary datetime field> ::=
YEAR
| MONTH
| DAY
| HOUR
| MINUTE
<time zone field> ::=
TIMEZONE_HOUR
| TIMEZONE_MINUTE
As you can see, "EPOCH" is not a valid extract field in the SQL standard.
However, I guess it is not a bad idea to improve jOOQ's EXTRACT()
implementation, at least for Postgres. I have registered #2132 for this:
https://github.com/jOOQ/jOOQ/issues/2132
In the mean time, you'll have to resort to plain SQL
Cheers
Lukas
2013/1/15 Pay Liu <[email protected]>:
> Hi Lukas and all,
>
> I use sql-plain to get unix time as below.
>
> SQL:
> select EXTRACT(epoch FROM now()) as unix_time (function datetime - epoch)
>
> JOOQ:
>
> Factory.field("EXTRACT(epoch FROM now())", Integer.class)
>
>
> I found Factory.extract(), it seem similar, but not.
>
> Can it be perfect or use sql-plain is one of solutions now?
>
> Thanks.
> -Pay
--
You received this message because you are subscribed to the Google Groups "jOOQ
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.