Is there a way in-code to determine the maximum length of a Integration Services Data Type.
I need to determine based on the data type what the maximum length of a column is IN-CODE.
However, the column.Length property only gives me a length for DT_WSTR and DT_STR values. This is the only property that would seem to remotely give me the right answer.
I need to know the maximum lengths in columns for DT_BOOL, DT_CY, DT_I2, DT_I4, DT_I8, DT_NUMERIC, and DT_UI1. I can always hard-code these values into my program, but that makes no sense. There has to be some sort of way to determine what the maximum possible length of these values are.
For numeric values I could use the column.Precision value but that still leaves with with a lot of data types without a maximum length.
It might help if you explain why you want to know this information.
A DT_I4 is 4 bytes long, for instance, but it can hold -2,147,483,648 to 2,147,483,647. So which value do you want? Do you see the problem?
Data types are fixed in what they can handle, so why not just hard code them into your "IN-CODE"?|||In your example, for DT_I4, -2,147,483,648 is a length of 11 (excluding commas, but including the sign). Thats the kind of value I need to know. I apologize if I wasn't clear on that.
Well, yes, I could hard-code them. But I was wondering whether that type of information is actually stored (which really if you think about it, shouldn't be that difficult, and also worthwhile so a person does not have the compute what each one would be).
Hard-coding is something you also try to avoid if there is a way to avoid it (and hence my question as to whether I can avoid this or not).
Thanks
|||But that's just it, the length of a DT_I4 is 4, not 11.
The "length" of 11 is not stored anywhere. It's a limitation of the storage allocated to the data type. There are probably internal bounds checks, but I'm guessing they are not exposed. You could always try one of the many programming forums in MSDN to see if someone has an idea, as this really isn't an SSIS issue. SSIS data types are simply mapped to structures in .Net.
And the max length of a DT_STR is 8000 bytes. DT_WSTR is 4000 bytes. But more importantly, there is no such thing as a DT_STR, DT_I4, etc... in code. So what SSIS has as limitations may not be the same as the structures available in your code. (A DT_I4 equates to the Integer (Int32) structure.)|||
theddern wrote:
Hi, Is there a way in-code to determine the maximum length of a Integration Services Data Type.
I need to determine based on the data type what the maximum length of a column is IN-CODE.
However, the column.Length property only gives me a length for DT_WSTR and DT_STR values. This is the only property that would seem to remotely give me the right answer.
I need to know the maximum lengths in columns for DT_BOOL, DT_CY, DT_I2, DT_I4, DT_I8, DT_NUMERIC, and DT_UI1. I can always hard-code these values into my program, but that makes no sense. There has to be some sort of way to determine what the maximum possible length of these values are.
For numeric values I could use the column.Precision value but that still leaves with with a lot of data types without a maximum length.
There is no maximum/minimum length for those data types. They are just what they are - they never change. The length simply isn't relevant.
-Jamie
|||
theddern wrote:
In your example, for DT_I4, -2,147,483,648 is a length of 11 (excluding commas, but including the sign).
No its not. The length of it is 4. 4 bytes that is.
If the value that you want is 11 then just cast it as a DT_STR and get the length of that.
-Jamie
|||So what you are saying is that I need to hard-code the lengths if I need to know those particular type of values?|||
theddern wrote:
So what you are saying is that I need to hard-code the lengths if I need to know those particular type of values?
Yes! I just can't see the value in knowing the "lengths" of data types.|||And to clarify, I need to know what the maximum length (in characters) a particular column can be if that particular data was transfered to a command delimited flat file.
I was trying to figure that out based on IDTSColumn90.DataType because that would be the most logical place to start.
|||Are you wanting the display length for each data type?|||
theddern wrote:
And to clarify, I need to know what the maximum length (in characters) a particular column can be if that particular data was transfered to a command (sic) delimited flat file.
Why? If it is a delimited file, who cares?|||If he wanted to document specs for a fixed-length output file, he would find these useful. |||
theddern wrote:
So what you are saying is that I need to hard-code the lengths if I need to know those particular type of values?
No. I'm saying you don't need to care.
|||
Phil Brammer wrote:
theddern wrote:
And to clarify, I need to know what the maximum length (in characters) a particular column can be if that particular data was transfered to a command (sic) delimited flat file.
Why? If it is a delimited file, who cares?
Very very very good point.
This seems a very strange thing to want to do.
|||Yes
No comments:
Post a Comment