concat NULL string

Questions and answers regarding general SQL and backend databases

concat NULL string

Postby andre1506345542 » Thu Feb 22, 2018 4:37 pm

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
andre1506345542
 
Posts: 42
Joined: Mon Sep 25, 2017 3:19 pm

Re: concat NULL string

Postby ROCLASI » Thu Feb 22, 2018 5:28 pm

Hi Andre,

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

Hope this helps.
Robert Ivens
SAN Developer / Servoy Valued Professional / Servoy Certified Developer

ROCLASI Software Solutions / JBS Group, Partner
Mastodon: @roclasi
--
ServoyForge - Building Open Source Software.
PostgreSQL - The world's most advanced open source database.
User avatar
ROCLASI
Servoy Expert
 
Posts: 5438
Joined: Thu Oct 02, 2003 9:49 am
Location: Netherlands/Belgium

Re: concat NULL string

Postby andre1506345542 » Thu Feb 22, 2018 6:33 pm

Thanks Robert,
That works.
Andre
andre1506345542
 
Posts: 42
Joined: Mon Sep 25, 2017 3:19 pm


Return to SQL Databases

Who is online

Users browsing this forum: No registered users and 4 guests

cron