type cast issue occuring inside "derived column" transformation.

  • 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??

  • 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.

  • 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

  • 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[/url] | Forum Netiquette
    For index/tuning help, follow these directions.[/url] |Tally Tables[/url]

    Twitter: @AnyWayDBA

  • 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

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply