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

TJX Companies
Charter Member
Charter Member
Posts: 17
Joined: Tue Mar 21, 2006 1:00 pm

How do I concatenate two input Character fields

Post by TJX Companies »

I am trying to take firstname and lastname fields and concatenate into a fullname in a transform stage and getting only firstname in fullname field. What am I missing here. I defined these are stage variables and deriving fullname stage variable.

This kind of concatenation worked with numeric fields in another job. :?
narasimha
Charter Member
Charter Member
Posts: 1236
Joined: Fri Oct 22, 2004 8:59 am
Location: Staten Island, NY

Post by narasimha »

How are you concatenating the fields?
Try Firstname:Lastname
Narasimha Kade

Finding answers is simple, all you need to do is come up with the correct questions.
Raghavendra
Participant
Posts: 147
Joined: Sat Apr 30, 2005 1:23 am
Location: Bangalore,India

Post by Raghavendra »

If you use Firstname: Lastname then should get the result.
I may be silly but can you check again if you have concatenated last name or not
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Make sure you have properly defined the LastName variable as char or varchar.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
TJX Companies
Charter Member
Charter Member
Posts: 17
Joined: Tue Mar 21, 2006 1:00 pm

Post by TJX Companies »

narasimha wrote:How are you concatenating the fields?
Try Firstname:Lastname
That is what I am trying. I am deriving the fullname by 'Svfirstname : Svlastname' and still getting only first name in the fullname field. All the stage variables are defined as varchar.
narasimha
Charter Member
Charter Member
Posts: 1236
Joined: Fri Oct 22, 2004 8:59 am
Location: Staten Island, NY

Post by narasimha »

Trim your input and check for NULL before concatenating. See if it helps
Narasimha Kade

Finding answers is simple, all you need to do is come up with the correct questions.
TJX Companies
Charter Member
Charter Member
Posts: 17
Joined: Tue Mar 21, 2006 1:00 pm

Post by TJX Companies »

[quote="narasimha"]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.
narasimha
Charter Member
Charter Member
Posts: 1236
Joined: Fri Oct 22, 2004 8:59 am
Location: Staten Island, NY

Post by narasimha »

Lets get some more details here.

What is your source? (File, DB,...)
Also can you post the exact derivation you have used for your Stage Variables.
Narasimha Kade

Finding answers is simple, all you need to do is come up with the correct questions.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

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.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
TJX Companies
Charter Member
Charter Member
Posts: 17
Joined: Tue Mar 21, 2006 1:00 pm

Post by TJX Companies »

[quote="narasimha"]Lets get some more details here.

What is your source? (File, DB,...)
Also can you post the exact derivation you have used for your Stage Variables.

My source is output from FTP_Plugin from a Windows Server ( Excel Spread sheet). How do I attach the screen shot here ? Or do I need to e-mail you the screen shot ( This is first time I am in a forum ).
TJX Companies
Charter Member
Charter Member
Posts: 17
Joined: Tue Mar 21, 2006 1:00 pm

Post by TJX Companies »

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.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

How are you asking for the length to be reported? Create more output columns - define their derivations to use the Len() function.

Is the output file fixed-width format? If so, the fields will always be padded to length.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
TJX Companies
Charter Member
Charter Member
Posts: 17
Joined: Tue Mar 21, 2006 1:00 pm

Post by TJX Companies »

ray.wurlod wrote:How are you asking for the length to be reported? Create more output columns - define their derivations to use the Len() function.

Is the output file fixed-width format? If so, the fields will always be padded to length.
Yes. The output file is fixed width format. That explains why I am getting the length that way. I will try your suggestion and get back to you. Thanks a lot.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Re: How do I concatenate two input Character fields

Post by ray.wurlod »

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.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
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 »

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 ?
Post Reply