Showing posts with label transformation. Show all posts
Showing posts with label transformation. Show all posts

Sunday, March 25, 2012

Conversion issues on Output Columns with Script Task

I am not sure which type to use for my Script Transformation Editor output fields. I'm getting errors based on the Data Type I'm specifying for my fields.

Print Screens:

http://www.webfound.net/script_task.jpg

TITLE: Package Validation Error

Package Validation Error


ADDITIONAL INFORMATION:

Error at Import Maintenance (mnt) File [Split HeaderRows into Columns [5176]]: Error 30512: Option Strict On disallows implicit conversions from 'Double' to 'UInteger'.
Line 21 Column 37 through 71
Error 30512: Option Strict On disallows implicit conversions from 'Double' to 'Long'.
Line 22 Column 35 through 69
Error 30512: Option Strict On disallows implicit conversions from 'Double' to 'Long'.
Line 23 Column 37 through 71
Error 30512: Option Strict On disallows implicit conversions from 'Double' to 'Long'.
Line 25 Column 27 through 61

Error at Import Maintenance (mnt) File [Split HeaderRows into Columns [5176]]: Error 30512: Option Strict On disallows implicit conversions from 'Double' to 'UInteger'.
Line 21 Column 37 through 71
Error 30512: Option Strict On disallows implicit conversions from 'Double' to 'Long'.
Line 22 Column 35 through 69
Error 30512: Option Strict On disallows implicit conversions from 'Double' to 'Long'.
Line 23 Column 37 through 71
Error 30512: Option Strict On disallows implicit conversions from 'Double' to 'Long'.
Line 25 Column 27 through 61

Error at Import Maintenance (mnt) File [DTS.Pipeline]: "component "Split HeaderRows into Columns" (5176)" failed validation and returned validation status "VS_ISBROKEN".

Error at Import Maintenance (mnt) File [DTS.Pipeline]: One or more component failed validation.

Error at Import Maintenance (mnt) File: There were errors during task validation.

(Microsoft.DataTransformationServices.VsIntegration)


BUTTONS:

OK

I'm not sure if this is needed but here's the script I coded in my script task also:

Imports System

Imports System.Data

Imports System.Math

Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper

Imports Microsoft.SqlServer.Dts.Runtime.Wrapper

Public Class ScriptMain

Inherits UserComponent

Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)

Dim strWholeRow As String = Row.OutputHeaderRows

Row.BatchDate = CStr(strWholeRow.Substring(0, 8))

Row.NotUsed = CStr(strWholeRow.Substring(9, 32))

Row.TransactionCode = CStr(strWholeRow.Substring(33, 34))

Row.GrossBatchTotalAmount = CDbl(strWholeRow.Substring(35, 44))

Row.NetBatchTotalAmount = CDbl(strWholeRow.Substring(45, 54))

Row.BatchTransactionCount = CDbl(strWholeRow.Substring(55, 59))

Row.PNETID = CStr(strWholeRow.Substring(60, 63))

Row.PartnerCode = CDbl(strWholeRow.Substring(64, 67))

Row.Filler = strWholeRow.Substring(68, 100)

End Sub

End Class

Looking at the screenshot and the code it looks like you're trying to put a decimal number into an integer column and you simply can't do that. You'll have to change either the type of the output column (try using DT_DECIMAL) or change CDbl to CInt.

-Jamie

Thursday, March 8, 2012

Contitional Split, LTRIM

I am trying to follow an SSIS tutorial. It is doing a transformation on mainframe data.

It has the statement LTRIM(State) == '' in the Condititonal split editor.

The data type is DT_STR.

Nothing works (dbl quote,brackets, ect)

I have also tried to change the type to DT_WSTR. According to docs ltrim only works with Unicode.

Can someone please tell me how to detect an empty string.

Thanks for any help

walter

Walter_Of_Maggie wrote:

I am trying to follow an SSIS tutorial. It is doing a transformation on mainframe data.

It has the statement LTRIM(State) == '' in the Condititonal split editor.

The data type is DT_STR.

Nothing works (dbl quote,brackets, ect)

I have also tried to change the type to DT_WSTR. According to docs ltrim only works with Unicode.

Can someone please tell me how to detect an empty string.

Thanks for any help

walter

In the conditional split, it'd best be done this way:

TRIM(State) == "" || ISNULL(State)|||

Hello Phil,

That did the trick. The book with the tutorial is Professional SQL Server2005 Integration Services (Wrox)

Is the syntax in the book just flat wrong? LTRIM(State) = '' One article I read said that LTRIM only works with Unicode.

Anyway, thanks for the help

Regards,

Walter

|||They do work with unicode only, but non-unicode gets implicity converted first.

LTRIM(State) = "" should work fine as well, unless the data is really NULL, not blank.|||

LTRIM(State) == "" Works now.

It didn't work last night.

I don't know how that.

Maybe it just doesn't work on Tuesday

Anyway, My package is working now. I appreciate your help.

Thanks again

Walter

|||Please mark the appropriate response as the answer to your question.

Thanks,
Phil|||

Walter_Of_Maggie wrote:

LTRIM(State) == ""

This is different from what you said on your post at the top of this thread. In there you said (and I've copied and pasted):

LTRIM(State) == ''

Walter_Of_Maggie wrote:

Works now.

It didn't work last night.

I don't know how that.

Maybe it just doesn't work on Tuesday

Anyway, My package is working now. I appreciate your help.

Thanks again

Walter

-Jamie

|||

Looks like I made a mistake. I was sure that the book had single quotes (which didn't work) But when I looked with a magnifying glass, they were double quotes.

Nevertheless, I am sure that last night, before I posted, I tried every conceivable syntax, single quotes,double quotes, brackets, even a regex. I got errors on everything.

I'm sorry for the confusion, it works now, that's it.

Thanks for the help

Walter

Sunday, February 19, 2012

Consuming a Recordset in a Script Transformation

I have a situation where I have created a recordset in a previous data flow task where the output was a recordset.

Now I want to write that recordset to a flat file.

There is no direct recordset input data flow source. So I thought I would use a source script transformation to read the recordset. Then I searched on this and found no information on how I might do this.

Anyone have any ideas on how to do this in a script transformation?

There are reasons that I would like to do it this way, but if I have to choose another way, well that's life.

Try this -

SSIS Junkie : SSIS: Recordsets instead of raw files
(http://blogs.conchango.com/jamiethomson/archive/2006/01/04/2540.aspx)

By the way I would consider raw files over this, especially if you have a lot of data.

|||

DarrenSQLIS wrote:

Try this -

SSIS Junkie : SSIS: Recordsets instead of raw files
(http://blogs.conchango.com/jamiethomson/archive/2006/01/04/2540.aspx)

By the way I would consider raw files over this, especially if you have a lot of data.

I echo what Darren has said. And if you need proof, go here:

Comparing performance of a raw file against a recordset destination
http://blogs.conchango.com/jamiethomson/archive/2006/06/28/4159.aspx

-Jamie