How can we have @variable in JOOQ?

无人久伴 提交于 2019-12-22 12:56:10

问题


I am trying to achieve something similar like the below MySql query in Jooq:

Select 
 CASE WHEN (datecolumn IS NULL) 
 THEN (@outerval:=@outerval+1) 
 ELSE (@outerval) END AS consec_set
From some_table;

How can we have @variable in JOOQ ?

Note: I am aware the equivalent for CASE WHEN in JOOQ but just want to know the @variable.

Jooq Version :3.0.1


回答1:


This is currently not supported in jOOQ 3.0. I have registered a feature request for this: https://github.com/jOOQ/jOOQ/issues/2558

I'm not sure how much support for variables can really be added to jOOQ in a useful way. But in any case, you can always resort to plain SQL:

Field<Integer> f1 = DSL.field("@outerval:=@outerval+1", Integer.class);
Field<Integer> f2 = DSL.field("@outerval", Integer.class);


来源:https://stackoverflow.com/questions/17318757/how-can-we-have-variable-in-jooq

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