How to use toChar function in JOOQ?

左心房为你撑大大i 提交于 2019-12-17 22:59:34

问题


I have to use toChar() function in JOOQ? Right now i have used below code

 TO_CHAR(PaymentDate, 'YYYY-MM-DD') <= TO_CHAR(SYSDATE,'YYYY-MM-DD')");

Which i have to convert into JOOQ. How to use this in JOOQ?


回答1:


Oracle's TO_CHAR() function is not explicitly supported by jOOQ 3.2. I have added a feature request for this: #2832.

In the mean time, you will have to resort to plain SQL as documented in the manual. For instance, you could write:

// Create reusable fields:
Field<String> f = DSL.field(
    "TO_CHAR({0}, 'YYYY-MM-DD')", String.class, T.PaymentDate);

// Create reusable conditions:
Condition c = DSL.condition(
    "TO_CHAR({0}, 'YYYY-MM-DD') <= TO_CHAR(SYSDATE, 'YYYY-MM-DD')", 
    T.PaymentDate);

Note that {0} is a reference to the first QueryPart argument of DSL.condition(String, QueryPart...), for instance.



来源:https://stackoverflow.com/questions/19855761/how-to-use-tochar-function-in-jooq

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!