Varchar field length

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
Curious George
Premium Member
Premium Member
Posts: 11
Joined: Tue Oct 29, 2013 7:25 pm
Location: USA

Varchar field length

Post by Curious George »

Hi All,

I'm trying to read a xml message into a varchar field. The length of the xml message could vary and I'm reading it into a single nvarchar field. As of now I have not defined any length for the nvarchar field as the length of the message could vary.

I have 2 approaches in mind:
1. Define a very high length so that the message does not cross that length
2. Dont define length for the nvarchar field and leave it as it is.

Please let me know which of the above 2 approaches would work well with DataStage v8.5

Thanks.
prasson_ibm
Premium Member
Premium Member
Posts: 536
Joined: Thu Oct 11, 2007 1:48 am
Location: Bangalore

Post by prasson_ibm »

In option 2 is better, dont define anything in length(unbounded), datastage will take the appropiate length and meomory.In case you use option1 and your message cross the length defined, datastage will discard the strings which are more then specified maximum length and process incomplete xml.
asorrell
Posts: 1707
Joined: Fri Apr 04, 2003 2:00 pm
Location: Colleyville, Texas

Post by asorrell »

Please note that as a rule it isn't a good idea to use unbounded strings except in cases where the length is truly unknown. DataStage will allocate a significant amount of space for any unbounded column.

In other words - don't be lazy and do this for all VARCHAR's - your jobs will take up a lot more memory (and probably run slower!).
Last edited by asorrell on Tue Dec 17, 2013 6:13 pm, edited 1 time in total.
Andy Sorrell
Certified DataStage Consultant
IBM Analytics Champion 2009 - 2020
Curious George
Premium Member
Premium Member
Posts: 11
Joined: Tue Oct 29, 2013 7:25 pm
Location: USA

Post by Curious George »

Hi All,

Thanks for your replies. As I mentioned I prefer defining the length of the varchar field but since its a response from some other system I dont have control over that and further they too told it is dynamic and change.

When we dont define the length for a varchar field what is the length that is assigned by DataStage?
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

It varies. Use OSH_PRINT_SCHEMAS environment variable to have DataStage report on schemas used, but it will not show a length for an unbounded VarChar.
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