Thanks Lukas!. Worked great !.. On Wednesday, 10 September 2014 02:13:20 UTC+5:30, Lukas Eder wrote: > > Hello Prem, > > There are essentially to solutions. > > 1. use a conditional expression for this: > > DSL.using(configuration) > .insertInto(TABLE) > > .set(...) > > .set(TABLE.COLUMN, longValue == 0L ? null : longValue) > .set(...) > > .execute(); > > > 2. use the jOOQ API and let the database decide whether to set longValue > or NULL: > > DSL.using(configuration) > .insertInto(TABLE) > > .set(...) > > .set(TABLE.COLUMN, DSL.nullIf(longValue, 0L)) > .set(...) > > .execute(); > > Hope this helps, > Lukas > > 2014-09-09 17:19 GMT+02:00 Prem Nair <[email protected] <javascript:>>: > >> Hello >> I am doing an *insertInto* and using *set* method. The value I am >> setting is a long and would like to set the field as null ( null is allowed >> in the field ) if the value is not present. In the PS I used setLong and >> setNull like the following >> >> * if (longValue != 0) {* >> * cstmt.setLong(7, longValue);* >> * } else {* >> * cstmt.setNull(7, Types.NULL);* >> * }* >> >> Any thoughts on how to archive the same in JOOQ >> >> Thanks >> Prem >> >> >> -- >> 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] <javascript:>. >> 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.
