SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


type cast issue occuring inside "derived column" transformation.


type cast issue occuring inside "derived column" transformation.

Author
Message
aveerabadran
aveerabadran
SSC-Enthusiastic
SSC-Enthusiastic (109 reputation)SSC-Enthusiastic (109 reputation)SSC-Enthusiastic (109 reputation)SSC-Enthusiastic (109 reputation)SSC-Enthusiastic (109 reputation)SSC-Enthusiastic (109 reputation)SSC-Enthusiastic (109 reputation)SSC-Enthusiastic (109 reputation)

Group: General Forum Members
Points: 109 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??
durga palepu
durga palepu
SSC Journeyman
SSC Journeyman (83 reputation)SSC Journeyman (83 reputation)SSC Journeyman (83 reputation)SSC Journeyman (83 reputation)SSC Journeyman (83 reputation)SSC Journeyman (83 reputation)SSC Journeyman (83 reputation)SSC Journeyman (83 reputation)

Group: General Forum Members
Points: 83 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.
kramaswamy
kramaswamy
SSCommitted
SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)

Group: General Forum Members
Points: 1511 Visits: 1803
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
Evil Kraig F
Evil Kraig F
SSCrazy Eights
SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)SSCrazy Eights (8.6K reputation)

Group: General Forum Members
Points: 8553 Visits: 7660
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. Hehe


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
drew.allen
drew.allen
SSCertifiable
SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)SSCertifiable (6.2K reputation)

Group: General Forum Members
Points: 6174 Visits: 10857
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
How to post data/code on a forum to get the best help.
How to Post Performance Problems
Make sure that you include code in the appropriate IFCode tags, e.g. [code=sql]<your code here>[/code]. You can find the IFCode tags under the INSERT options when you are writing a post.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search