How do I concatenate two input Character fields

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Nageshsunkoji
Participant
Posts: 222
Joined: Tue Aug 30, 2005 2:07 am
Location: pune
Contact:

Re: How do I concatenate two input Character fields

Post by Nageshsunkoji »

TJX Companies wrote:
ray.wurlod wrote:
TJX Companies wrote:This kind of concatenation worked with numeric fields in another job. :?
Just noticed this in the original post. Which suggests to me that the other job was a server job.
Hi, The job which worked is a parallel job. But the Input Sequential file is coming from a server job. Does that make any difference ?
Hi,
I don't think so, any problem with sequentail file.
Debug your job in the following way.
Try this way, first see the input data of any row.
For Ex: FirstName : John LastName:Lewis
Eventhough your filed length is 20 and Varchar. Just use substring for getting above row. Means FirstNameSvr[1,4]:LastNameSvr[1,5].

Now,check the result . if your getting the right result. That means your input data is padded with some strane value (may be ASCII null). If not, we have to try another way to debug your problem.
NageshSunkoji

If you know anything SHARE it.............
If you Don't know anything LEARN it...............
baglasumit21
Participant
Posts: 132
Joined: Wed Mar 01, 2006 11:12 pm
Location: Pune

Post by baglasumit21 »

TJX Companies wrote:
narasimha wrote:Trim your input and check for NULL before concatenating. See if it helps

Hi Narasimha, I tried with Trim too. It didn't worked. Is there any specific trim function I should be using ? I tried 'Trim' and 'TrimLeadingTrailing' and both didn't work.
Try using ltrim and rtrim for eg. ltrim(rtrim(stgFName)) : ltrim(rtrim(stgLName)) and also check the size of source and target fields
SMB
baglasumit21
Participant
Posts: 132
Joined: Wed Mar 01, 2006 11:12 pm
Location: Pune

Post by baglasumit21 »

TJX Companies wrote:
ray.wurlod wrote:Nothing should be in quotes.

Create another output link from the Transformer stage containing the values from the stage variables and the value from the derivation. Run this into, say, a Peek stage; inspect the results and diagnose.

You may discover (for example) that LastName is truly empty in some of your source records.
Hi, That is what I am actually doing to diagnose the problem. I am creating a output with just the fullname, firstname and lastname. The first and last name stage variables are defined as 20 varchar but when I tried to find the length I am getting 20. It is as if the white space is counted too. I tried all options like (Whitespace, Trim, TrimLeadingTrailing) and all of these are returning back the length of these fields as 20. This is what is confusing me a lot.

try to use len(ltrim(rtrim(stgName))) to find the length of the field
SMB
TJX Companies
Charter Member
Charter Member
Posts: 17
Joined: Tue Mar 21, 2006 1:00 pm

Re: How do I concatenate two input Character fields

Post by TJX Companies »

Nageshsunkoji wrote:
TJX Companies wrote:
ray.wurlod wrote: Just noticed this in the original post. Which suggests to me that the other job was a server job.
Hi, The job which worked is a parallel job. But the Input Sequential file is coming from a server job. Does that make any difference ?
Hi,
I don't think so, any problem with sequentail file.
Debug your job in the following way.
Try this way, first see the input data of any row.
For Ex: FirstName : John LastName:Lewis
Eventhough your filed length is 20 and Varchar. Just use substring for getting above row. Means FirstNameSvr[1,4]:LastNameSvr[1,5].

Now,check the result . if your getting the right result. That means your input data is padded with some strane value (may be ASCII null). If not, we have to try another way to debug your problem.
The substring worked. Thanks a lot.
TJX Companies
Charter Member
Charter Member
Posts: 17
Joined: Tue Mar 21, 2006 1:00 pm

Post by TJX Companies »

baglasumit21 wrote:
TJX Companies wrote:
narasimha wrote:Trim your input and check for NULL before concatenating. See if it helps

Hi Narasimha, I tried with Trim too. It didn't worked. Is there any specific trim function I should be using ? I tried 'Trim' and 'TrimLeadingTrailing' and both didn't work.
Try using ltrim and rtrim for eg. ltrim(rtrim(stgFName)) : ltrim(rtrim(stgLName)) and also check the size of source and target fields
Hi, I am getting error using Ltrim and Rtrim. But I tried Substring and the problem is resolved. Thanks a lot your time.
Post Reply