Page 1 of 1

Unusual Behaviour with String Data

Posted: Mon Oct 17, 2005 10:25 pm
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.

Posted: Mon Oct 17, 2005 10:36 pm
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?

Posted: Mon Oct 17, 2005 10:42 pm
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?

Posted: Tue Oct 18, 2005 3:48 am
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.