Hi Rafael,

The best way to construct dynamic SQL like this is to store the Condition
in a local variable as such:

Condition condition = DSL.trueCondition();

if (exists)
    condition = condition.and(... your additional where clause ...)

create.selectFrom(table("mytable")).where(condition).fetch();


The DSL.trueCondition() will just generate "1 = 1" in the SQL output.

Hope this helps,
Lukas

2015-10-22 15:16 GMT+02:00 Rafael da Silva Monteiro Leite <
[email protected]>:

> Hi,
>
> I have one question, have this select in jooq:
>
>
>        SelectWhereStep<Record> selectFrom =
> create.selectFrom(table("mytable"));
>
>
> after create selectFrom , in java have one condition, where 'exist' is
> sent through parameter:
>
>        if(exist){
>             here I add clause where in selectFrom
>        }
>
> and have more condition, where if condition is true I add other clause;
>
> Is this possible?
> How can I create this?
>
> --
> 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.
>

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