Page 1 of 1

Varchar field length

Posted: Tue Dec 17, 2013 4:01 pm
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.

Posted: Tue Dec 17, 2013 5:31 pm
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.

Posted: Tue Dec 17, 2013 6:09 pm
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!).

Posted: Tue Dec 17, 2013 9:02 pm
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?

Posted: Wed Dec 18, 2013 1:56 am
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.