Possible truncation of variable length string

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
karthi_gana
Premium Member
Premium Member
Posts: 729
Joined: Tue Apr 28, 2009 10:49 pm

Possible truncation of variable length string

Post by karthi_gana »

All,

I have a simple job which will generate the header and current date.
The job design is:

Row Generator --> Tranformer --> Export Column --> SeqFile

Header1 varchar(20)
Header2 varchar(20)

'UHDR' = Header1
DateToString(currentdate(),"%yyyy%ddd") = Header2

export_header:

exported_col varchar(255)

header1 & header2 will be stored in 'exported_col' as below


UHDR|2011101


when i run the job, i am getting the below error message.

export_header: When checking operator: When binding output interface field "exported_col" to field "exported_col": Implicit conversion from source type "string" to result type "string[max=255]": Possible truncation of variable length string.

why? I don't understand this error message.
Karthik
jwiles
Premium Member
Premium Member
Posts: 1274
Joined: Sun Nov 14, 2004 8:50 pm
Contact:

Post by jwiles »

In your job, the column export stage is outputting an unbounded varchar() column (no defined max length). By placing a length of 255 on the output link metadata for the column, you have told the parallel engine to limit the length to 255 bytes (bounded varchar() ). This is done immediately after the operator when the job runs (look in the generated OSH for a modify statement attached to the output of the export operator). The warning is there because of the change from unbounded to bounded varchar().

Regards,
- james wiles


All generalizations are false, including this one - Mark Twain.
karthi_gana
Premium Member
Premium Member
Posts: 729
Joined: Tue Apr 28, 2009 10:49 pm

Post by karthi_gana »

How to avoid this warning message? if i specify char(255), will it resolve the warning message?
Karthik
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Always specify a maximum string length (VarChar(255) for example) or always specify unbounded VarChar.

There are pros and cons to both approaches, discussed elsewhere.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
karthi_gana
Premium Member
Premium Member
Posts: 729
Joined: Tue Apr 28, 2009 10:49 pm

Post by karthi_gana »

you mean

Header1 varchar(255)
Header2 varchar(255)

something like this..
Karthik
karthi_gana
Premium Member
Premium Member
Posts: 729
Joined: Tue Apr 28, 2009 10:49 pm

Post by karthi_gana »

ray.wurlod wrote:Always specify a maximum string length (VarChar(255) for example) or always specify unbounded VarChar.

There are pros and cons to both approaches, discussed elsewhere.
It is already specifiad as varchar(255) only. :roll:
Karthik
karthi_gana
Premium Member
Premium Member
Posts: 729
Joined: Tue Apr 28, 2009 10:49 pm

Post by karthi_gana »

unbounded VarChar
how should i specifiy it?
Karthik
rohithmuthyala
Participant
Posts: 57
Joined: Wed Oct 21, 2009 4:46 am
Location: India

Post by rohithmuthyala »

Do not specify any limit define it as varchar()..!
Rohith
karthi_gana
Premium Member
Premium Member
Posts: 729
Joined: Tue Apr 28, 2009 10:49 pm

Post by karthi_gana »

rohithmuthyala wrote:Do not specify any limit define it as varchar()..!
Yes. It works fine now.
Karthik
Post Reply