Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: SQL Expression Error When Concatenating fields Post Reply Post New Topic
Author Message
vijayk
Groupie
Groupie


Joined: 14 Mar 2007
Location: United States
Online Status: Offline
Posts: 53
Quote vijayk Replybullet Topic: SQL Expression Error When Concatenating fields
     Posted: 28 Mar 2008 at 6:58am
Hi,
 
I am doing a straight forward concatenation of 2 database fields. It is giving me the following error.
 
SQL Expression looks like
 
"A"."TYP_CD"+"A"."JNL_NO"
 
Error is
 
Database Connect Error : 42815: SQL0171N The data type, length or value of the argument "1" of routine "+" is incorrect . SQL state 42815.
 
Does anyone see an issue.?
 
Thanks,
Vijay
IP IP Logged
dave_wright
Newbie
Newbie


Joined: 27 Mar 2008
Location: United Kingdom
Online Status: Offline
Posts: 6
Quote dave_wright Replybullet Posted: 28 Mar 2008 at 8:31am
NOTE: Only be using Crystal for a few days so hope this helps ...

I tried the Concatenation with + and found odd results coming back akin to issues I'd seen with MySQL concat vs. concat_ws

The answer I came up with was:

{fn CONCAT({fn IFNULL(`tblperson1`.`SurName`, '')}, ', ',{fn IFNULL(`tblperson1`.`FirstName`, '')}, '. ' , {fn IFNULL(`tblperson1`.`MIddleName`, '')})}

So it puts a blank if a null field but outputs:
Surname, Firstname. Middlename
or at least the value's within those fields.

I could be making it more complicated or I've missed something but the answer I came up with at least works for me
 
IP IP Logged
vijayk
Groupie
Groupie


Joined: 14 Mar 2007
Location: United States
Online Status: Offline
Posts: 53
Quote vijayk Replybullet Posted: 28 Mar 2008 at 9:21am
Thanks . It did work perfectly.
 
Vijay
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum