import org.jooq.*;
import org.jooq.conf.RenderNameStyle;
import org.jooq.conf.Settings;
import org.jooq.impl.DSL;
import static org.jooq.impl.DSL.*;
public class JooqExamples {
private static Settings settings = new Settings()
.withRenderNameStyle(RenderNameStyle.AS_IS).withRenderFormatted(true);
private static DSLContext dsl = DSL.using(SQLDialect.DEFAULT, settings);
public static void main(String[] args) {
Long empid = 1234l;
Field<?> employeeStatus =
// Excepting here it should generate ?
when(field("emp.mgr_level").isNotNull(), "MANAGER")
.otherwise("employee").as("employee_status");
SelectConditionStep<? extends Record1<?>> select = dsl
.select(employeeStatus)
.from(table("employee").as("emp"))
// how to bind the variable
.where(field("emp.id").eq(empid));
System.out.println(select.getSQL());
}
}
select case when emp.mgr_level is not null then ? else ? end employee_statusfrom employee empwhere emp.id = ?
--
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 jooq-user+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
import org.jooq.*;
import org.jooq.conf.RenderNameStyle;
import org.jooq.conf.Settings;
import org.jooq.conf.StatementType;
import org.jooq.impl.DSL;
import static org.jooq.impl.DSL.*;
/**
* Created by mohan on 6/6/2017.
*/
public class JooqExamples {
private static Settings settings = new Settings()
.withRenderNameStyle(RenderNameStyle.AS_IS).withRenderFormatted(true);
//.withStatementType(StatementType.STATIC_STATEMENT);
private static DSLContext dsl = DSL.using(SQLDialect.DEFAULT, settings);
public static void main(String[] args) {
Long empid = 1234l;
Field<?> employeeStatus =
when(field("emp.mgr_level").isNotNull(), inline("MANAGER"))
.otherwise(inline("employee")).as("employee_status");
SelectConditionStep<? extends Record1<?>> select = dsl
.select(employeeStatus)
.from(table(name("employee")).as("emp"))
.where(field("emp.id").eq(param("empId",empid)));
System.out.println(select.getSQL());
System.out.println(select.getBindValues());
}
}
select case when emp.mgr_level is not null then 'MANAGER' else 'employee'
[1234]
select case when emp.mgr_level is not null then 'MANAGER' else 'employee'
end employee_statusfrom employee emp
To unsubscribe from this group and stop receiving emails from it, send an email to jooq-user+...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to jooq-user+unsubscribe@googlegroups.com.