How to truncate Chinese Char ?

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
anu123
Premium Member
Premium Member
Posts: 143
Joined: Sun Feb 05, 2006 1:05 pm
Location: Columbus, OH, USA

How to truncate Chinese Char ?

Post by anu123 »

Hi All,

Is there any function or method we have in DataStage to truncate the value of Chinese Char from 100 to 50 ?

Please suggest me .
Thank you,
Anu
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Suggest you clarify your requirement. Do you mean you need to substring off the first 50 characters of a 100 character string? :?
-craig

"You can never have too many knives" -- Logan Nine Fingers
anu123
Premium Member
Premium Member
Posts: 143
Joined: Sun Feb 05, 2006 1:05 pm
Location: Columbus, OH, USA

Post by anu123 »

Yes , i want first 50 positions of a 100 character string. I tried with substr & [1,50], but its not working.
Thank you,
Anu
sudha03_vpr
Participant
Posts: 34
Joined: Tue Feb 26, 2013 9:36 am
Location: Chicago

Post by sudha03_vpr »

Does your NLS Char set in Datastage support the Chinese character set ? What is the error that you get when you use column1[1,50] ?
sudha03_vpr
Participant
Posts: 34
Joined: Tue Feb 26, 2013 9:36 am
Location: Chicago

Post by sudha03_vpr »

Instead of doing this in the Transformer you can extract only those 50 characters from the database.

Eg : SELECT SUBSTR(NAME,1,10) FROM CUSTOMER
anu123
Premium Member
Premium Member
Posts: 143
Joined: Sun Feb 05, 2006 1:05 pm
Location: Columbus, OH, USA

Post by anu123 »

I am reading from .txt file and trying to load in to DB2
We have NLS as UTF-8

Error : [IBM][CLI Driver][DB2/AIX64] SQL0302N The value of a host variable in the EXECUTE or OPEN statement is out of range for its corresponding use. SQLSTATE=22001
Thank you,
Anu
sudha03_vpr
Participant
Posts: 34
Joined: Tue Feb 26, 2013 9:36 am
Location: Chicago

Post by sudha03_vpr »

Instead of table, can you load the data to the flat file and check if you have any special/ chinese characters .
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The inbuilt functions that you are likely to use, like [1,50] or Substring(), or Left(), all operate on characters (not on bytes). So, provided you have specified the correct character map (the one used to encode the data, for example BIG5 or GB2312) then all should be well.

The error message does not appear to be about characters and substringing. Check your DB2 error manual to understand more fully what error code SQL0302N means and its probable resolution.

Please post your findings back here.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
anu123
Premium Member
Premium Member
Posts: 143
Joined: Sun Feb 05, 2006 1:05 pm
Location: Columbus, OH, USA

Post by anu123 »

Hi Ray,

I found the info from the link below and tried by changing the field type as nvarchar in DS and not changed in the table , so that could be a reason for failing again with same error .

"To resolve this issue, you can triple the original varchar precision and size, or you can change the data type to nvarchar."

http://pic.dhe.ibm.com/infocenter/caapp ... iable.html
Thank you,
Anu
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

That, in turn, really depends on whether the database specifies characters or bytes for storage. If bytes, then a multiplier is definitely indicated, and will usually occur automatically when the table definition is imported. We found with most encodings of Japanese data that a factor of 3 was correct; however if there is a prevalence of double-width characters in your Chinese data a factor of 4 may be more appropriate.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply