Page 1 of 1

concat NULL string

PostPosted: Thu Feb 22, 2018 4:37 pm
by andre1506345542
Hi,

I try with query builder to concat some text and number fields together. It works as long as the fields are not null. If one of the fields is null, to complete concated string is null.
query.result.add(query.columns.field1.concat(' ').concat(query.columns.field2).concat(' ').concat(

query.result.add(query.columns.field1.concat(' ').concat(query.columns.field2).concat(' ').concat(query.columns.field3).concat(' ').concat(query.columns.field4));

In my situation field4 can be sometimes null.

I know this is standard sql behavior.
I have tried to cast the field to QUERY_COLUMN_TYPES.TYPE_STRING and QUERY_COLUMN_TYPES.TYPE_TEXT, without any success.

Any ideas.
Thanks
Andre

Re: concat NULL string

PostPosted: Thu Feb 22, 2018 5:28 pm
by ROCLASI
Hi Andre,

You might want to look at the COALESCE() function. SQL has it, looks like QueryBuilder supports it as well.

Hope this helps.

Re: concat NULL string

PostPosted: Thu Feb 22, 2018 6:33 pm
by andre1506345542
Thanks Robert,
That works.
Andre