Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

type cast issue occuring inside "derived column" transformation. Expand / Collapse
Author
Message
Posted Tuesday, July 8, 2008 7:53 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Thursday, May 15, 2014 3:17 AM
Points: 53, Visits: 291
Hi All,
I face a type cast issue occuring inside "derived column" transformation.

Following is the error msg get:
[Derived Column [34]] Error: The "component "Derived Column" (34)" failed because error code 0xC0049064 occurred, and the error row disposition on "output column "new amt" (173)" specifies failure on error. An error occurred on the specified object of the specified component.

I will explain my transformations:

flat file source -> derived column -> OLE DB destination

Flat file:
The flat file is fixed width delimiter. it has 3 parts in it.
1st is 'Indicator' column , which is declared as 'string'
2nd is 'Amount' column , which is declard as 'string' [this is actually decimal , but declared as string in flat file definition for appending with 'sign' column]
3rd is 'Sign' column , which is declared as 'string' [this tells if the amount column is positive or negative number]

Derived column:

In this expression , i am tyring to concatenate the sign with the amount , and then typecase it to decimal , so that i can divide this value by 100.

to achieve this, i add a new column 'new amt' in it, which has the following expression in it - (DT_DECIMAL,10)(sign + amt)/100
This derived column is of datatype decimal[DT_DECIMAL]

OLE DB Destination:

destination table structure-
indi varchar(5)
amt decimal(10,2)

mapping:
Indicator -> indi
new amt -> amt

Example:

Flat file
DA1112679088-

if the flat file is like the above , then my destination table should be like this:

Destination table:

indi amt
DA -11126790.88

Can anyone help me in resolving the problem??
Post #530042
Posted Friday, August 26, 2011 11:16 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Tuesday, September 6, 2011 10:10 AM
Points: 57, Visits: 46
Hi,
Your requirement looks interesting.
But the 'amt+sign' is still returns string type and I guess derived column can not type cast it to decimal type.

I suggest instead apply /100 on amt and then concatenate the result with sign and keep it as string type only.

Regards,
Durga.
Post #1166298
Posted Friday, August 26, 2011 11:38 AM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Monday, July 21, 2014 7:44 PM
Points: 817, Visits: 1,646
First off, instead of using DT_DECIMAL, I'd recommend using DT_NUMERIC. Since you're dividing by 100, I assume you're looking for a value with two decimal places. This will allow you to specify your precision.

Second, you could change your task to this instead, which would allow you to have your output as a number instead of a string:

(DT_NUMERIC,12, 2) ((DT_I1) (sign + "1") * amt) / 100
Post #1166330
Posted Friday, August 26, 2011 11:50 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 9:15 PM
Points: 6,249, Visits: 7,403
aveerabadran (7/8/2008)
Hi All,
I face a type cast issue occuring inside "derived column" transformation.

Following is the error msg get:
[Derived Column [34]] Error: The "component "Derived Column" (34)" failed because error code 0xC0049064 occurred, and the error row disposition on "output column "new amt" (173)" specifies failure on error. An error occurred on the specified object of the specified component.


That's lovely and non-specific. Sigh. Google-Fu didn't help me either.


The flat file is fixed width delimiter.


Heheh, that's kind of an oxymoron, but I get where you're going. Usually we just say 'fixed width'. I had to come back and re-read that after your further explanation. My brain only remembered the 'delimited' part of that comment.


to achieve this, i add a new column 'new amt' in it, which has the following expression in it - (DT_DECIMAL,10)(sign + amt)/100
This derived column is of datatype decimal[DT_DECIMAL]


What I usually do in these cases is try to figure out why some of my rows are failing. The easiest way to do that is to create a second data-target (I usually use Recordset Destination so it dies when I restart the process and don't have file everywhere), and redirect my error rows, using a data viewer on the redirection to see what failed. At least then I can see the data that's causing the fail and work from there.

My guess would either be strange spacing in the fixed width field, something larger then expected, or an odd character in the sign position.

If that doesn't help, can you please copy and paste the expression, a few rows from your base file, and your fixed width file definition you created in the datasource?



- Craig Farrell

Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.

For better assistance in answering your questions | Forum Netiquette
For index/tuning help, follow these directions. |Tally Tables

Twitter: @AnyWayDBA
Post #1166336
Posted Friday, August 26, 2011 2:03 PM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Tuesday, September 3, 2013 8:24 AM
Points: 1,240, Visits: 5,421
Save yourself some trouble and combine your columns 2 and 3 into one column with the appropriate numeric type. SSIS can handle postfixed signs.

Drew


J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
Post #1166428
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse