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());
    }
}


Above code generates the below sql

select case when emp.mgr_level is not null then ?
            else ?
       end employee_status
from employee emp
where emp.id = ?

I have the following questions


   1. In the case statements, I was expecting to get the String values
   2. How to bind the empId if I want to us named parameters?


-- 
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/d/optout.

Reply via email to