问题
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