Hi Shyam,

I understand, so your *cn *table doesn't contain the field *"HC1_LEAF_ID"*.
>From how I understand your requirement, you shouldn't join the *cd *table
at all, in that case. This is a regular "dynamic SQL" problem, which can be
resolved like this:

Table<?> t = cn.join(hp).on(hp.PLANE_ID.eq(cn.field("PLANE_ID")));


// Join the cd table only if necessary / possible

if (cn.field("HC1_LEAF_ID") != null) {

    t = t.join(cd).on(cn.field("HC1_LEAF_ID").eq(cd.HC1_LEAF_ID));

}

Result a = ctx.select(cn.field("ID"))
              .from(t)

              .fetch();


Does this answer your question?

2014-02-18 8:59 GMT+01:00 Sha <[email protected]>:

> Sorry for confusion Lukas,
> Let me give more details.
>
> I have a scenarios here
>
> Result a =  ctx.select(cn.field("ID")).from(cn)
>   .join(hp)
>   .on( hp.PLANE_ID.eq(cn.field("PLANE_ID")) )
>   .join(cd)
>   .on( *(cn.field("HC1_LEAF_ID")).eq((cd.HC1_LEAF_ID).nullif(0))*)
>   .fetch();
>
> In the above , there is a condition .on(
> *(cn.field("HC1_LEAF_ID")).eq((cd.HC1_LEAF_ID).nullif(0))*).
> In which currently *cn.field("HC1_LEAF_ID") = null. *So i am not able to
> compare it if it is equal to *cd.HC1_LEAF_ID.*
> Is there any easy way/build-in-method to check , if the  
> *cn.field("HC1_LEAF_ID")
> not equal null* then only check if it is equal to *cd.HC1_LEAF_ID ? *In
> one statement.
>
> Thank you.
> ~Shyam
>
>
>
>
> On Monday, February 3, 2014 8:09:29 PM UTC+5:30, Lukas Eder wrote:
>
>> Hi Shyam,
>>
>> In general, jOOQ maps Java null to SQL NULL/UNKNOWN just like JDBC does
>> as well. I wasn't aware of SQL Server providing a way to distinguish NULL
>> from "EMPTY". Could you provide an example where you think that jOOQ should
>> change its behaviour?
>>
>> Cheers
>> Lukas
>>
>>
>> 2014-02-03 Sha <[email protected]>:
>>
>>> Hi Lukas,
>>>   When I try to fetch records of any table, when there is no value for a
>>> field JOOQ select statement fetching it as null.
>>> In many databases , especially SQLServer no value is treated as empty
>>> value.
>>>
>>> But by JOOQ why it is null , which in turn showing NullPointerException.
>>> And how to evaluate it to empty value ?
>>>
>>> Regards,
>>> ~Shyam
>>>
>>>  --
>>> 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/groups/opt_out.
>>>
>>
>>  --
> 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/groups/opt_out.
>

-- 
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/groups/opt_out.

Reply via email to