Jump to content

how to get rid of nulls in a concatenated string?


dprogrammer

Recommended Posts

I have a concatenated string like the following and some values can be null. I want the null values to be "" (blank) so that I don't see nulls. But its not working.

$F{AMOUNT1}==null?"":$F{AMOUNT1}+"n"+
$F{AMOUNT2}==null?"":$F{AMOUNT2}+"n"+
$F{AMOUNT3}==null?"":$F{AMOUNT3}+"n"

Current outPut:

9000000
6000000
null

Desired output:

9000000
6000000
 

 

Link to comment
Share on other sites

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

Hello,

I am not sure to well understand your problem, but, as for me, everytime I have to concatenate strings with some of them possibly null, I do that in the sql query with the nvl function.

In your case (oracle syntax) :

select nvl(to_char(Amount1),'')||nvl(to_char(Amount2),'')||nvl(to_char(Amount3),'') as Field1 ....

Hope this helps

Gaby

Link to comment
Share on other sites

The best option:

Go -> Edit -> Report properties -> i18n

3 combo list -> Cuando falte un tipo de recurso (I have in spanish)

select blank, this by default is null because is field dont have data print null.

Now in your report, if a fields dont have data this print blank.

 

Other Option:

($F{AMOUNT1}.equals(new String("null"))?new String(""):new String($F{AMOUNT1}).concat("n"))

 

I dont know if this is null or NULL or Null

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...