Unusual Behaviour with String Data

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
loveojha2
Participant
Posts: 362
Joined: Thu May 26, 2005 12:59 am

Unusual Behaviour with String Data

Post by loveojha2 »

Hi All,

I have a server job which is transferring data from source to target.
My Source and Target table are like this
Src_Table
Col1 Char(10)

Tgt_Table
Col1 Char(10)

In my source stage I am specifying column defintion as
Col1 Char(2)

And in target
Col1 Char(10)

In between the Source and target stages i am using a transformer, which is not doing any transforms (just for the purpose of having different lengths on both links).
The source table is containing one row 'abcdefghij'.
The output I am expecting is 'ab'.
But I am getting 'abc'. Any Ideas Why?(one extra character) :?:
Thanx in advance.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You need to truncate the data explicitly, for example

Code: Select all

Left(InLink.Col1,2)
I suspect what you're seeing results from C string handling; in C a string is an array of characters, and all array indexes are zero based. So you're seeing Col1[0], Col1[1] and Col1[2]. But that's just a guess. Do it right and you won't have the problem.

Incidentally, what do you see when viewing the target table with something other than DataStage's data browser?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
loveojha2
Participant
Posts: 362
Joined: Thu May 26, 2005 12:59 am

Post by loveojha2 »

The target table is also showing 'abc'.
You need to truncate the data explicitly, for example Code:
Left(InLink.Col1,2)


I suspect what you're seeing results from C string handling; in C a string is an array of characters, and all array indexes are zero based. So you're seeing Col1[0], Col1[1] and Col1[2]. But that's just a guess. Do it right and you won't have the problem.

Incidentally, what do you see when viewing the target table with something other than DataStage's data browser?
Andal
Participant
Posts: 124
Joined: Thu Dec 02, 2004 6:24 am
Location: Bangalore, India

Post by Andal »

Love,

I had experienced the same with Hash file also. If we specify the length as 1 , it is returning 2 characters. I did some workarounds for it, but still not able to find it.
Rgds
Anand
Post Reply