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

Monday, February 20, 2012

Newbie: Simple data transformation

Hi I have the following table:
tblMeasurement
StationID, PollutantCode, Value
e.g.
01220 013 23.4
01122 011 7.8
...
I want to make a simple transformation-update to the data :
IF the code is 013 then multiply the value by 0.2 and replace the existing
value, etc.
Is this part of UPDATE? I can't seem to find a simple example anywhere .
TIA
-steveTry,
update tblMeasurement
set Value = Value * 0.02
where PollutantCode = '013'
go
AMB
"steve" wrote:

> Hi I have the following table:
> tblMeasurement
> StationID, PollutantCode, Value
> e.g.
> 01220 013 23.4
> 01122 011 7.8
> ....
> I want to make a simple transformation-update to the data :
> IF the code is 013 then multiply the value by 0.2 and replace the existing
> value, etc.
> Is this part of UPDATE? I can't seem to find a simple example anywhere .
> TIA
> -steve
>
>

Newbie: Now getting return value, but need help debugging OLE DB Command Transformation

Good morning, all,

OK, I have read a ton of posting on this issue, but either they don't give enough information or they are for packages which use the Execute SQL command, whereas I am using the OLE DB Command Data Flow Transformation.

I have an Excel spreadsheet that we are receiving from agencies with rows of client data which I have to load into an application that is ready to go live. I also have a stored procedure spClientsInsertRcd, which was written for the application. In the normal flow of the application, the stored procedure is called from a Coldfusion page, which does some processing prior to calling it. So, I have written a 'wrapper' stored procedure, spImportAgencyData, which does the processing and then calls the spClientInsertRcd.

My dataflow has the following components:

An Excel Source, containing my test data, consisting of just one row of data,

which points to a

Derived Column Transformation, which reformats the SSN and adds a user variable, named returnValue with an Expression value of @.[User::returnvariable] set to a four-byte signed integer, which (i think) I need to get the value out of the stored procedure.

which points to a

Data Conversion Transformation, which takes care of all the datatype conversions

which points to a

OLE DB Command, which contains the following as the SQL Command:

exec ?= spImportAgencyData ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?

In the OLE DB Command, I have mapped returnValue, my user variable to @.RETURN_VALUE.

Right now, I am in initial testing. The dataflow shows that it is succeeding, but my one data record for testing is not getting inserted. I need to get the value of returnValue to figure out what is happening.

How do I get the value of the returnValue? I have tried putting a recordset destination after the OLE DB command, but that just gives me the data that went into the OLE DB Command.

Thanks,
Kathryn

OK,

I have made a few changes to the package and I can get a return value. The problem is that the data, which is currently only one row in an Excel worksheet, is not getting loaded.

The OLE DB Command's SQL Command is now:

exec spImportAgencyData ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,? output

with the final parameter being an output parameter. On the Column Mappings tab, I have mapped the output parameter @.returnValue which is in the Available Destination Columns to the returnValue variable (in the Available Input Columns) I created earlier in the Derived Column Transformation.

I have added a recordset Destination after the OLE DB Command and I only have the returnValue column in it.

The returnValue is always being returned as 0, which is either because I am not mapping it correctly or because the data is not getting loaded, I'm not sure which.

I can run the stored procedure from SQL Server Management Studio as

DECLARE @.returnValue int

EXEC [dbo].[spImportAgencyData]

@.URN = NULL,

@.FirstName = N'Kathryn',

@........

@.returnValue = @.returnValue OUTPUT

SELECT @.returnValue as N'@.returnValue'

and the correct new ClientID is returned, so the stored procedure is working. I have put a Data Viewer right before the OLE DB Command and run the stored procedure with the exact data coming from the Excel spreadsheet, just to double check and it runs and returns the new Client ID.

Does anyone have any tips on debugging this problem?

Thanks,
Kathryn

|||I had a similar issue (return a value from a stored procedure with 2 Varchar parameters), and eventually this is how I configured the Execute SQL Task:

General:

Connection Type: OLE DB
SQL Statemenet: EXEC ? = AUDIT.LoggingStoredProcedure ?, ?
Bypass Prepare: True

Parameter Mapping:

[Variable Name] | [Direction] | [Data Type] | [Parameter Name]
User::ReturnValue | Return Value | Long | 0
User::Parameter1 | Input | VARCHAR | 1
USer::Parameter2 | Input | VARCHAR | 2


Newbie: Now getting return value, but need help debugging OLE DB Command Transformation

Good morning, all,

OK, I have read a ton of posting on this issue, but either they don't give enough information or they are for packages which use the Execute SQL command, whereas I am using the OLE DB Command Data Flow Transformation.

I have an Excel spreadsheet that we are receiving from agencies with rows of client data which I have to load into an application that is ready to go live. I also have a stored procedure spClientsInsertRcd, which was written for the application. In the normal flow of the application, the stored procedure is called from a Coldfusion page, which does some processing prior to calling it. So, I have written a 'wrapper' stored procedure, spImportAgencyData, which does the processing and then calls the spClientInsertRcd.

My dataflow has the following components:

An Excel Source, containing my test data, consisting of just one row of data,

which points to a

Derived Column Transformation, which reformats the SSN and adds a user variable, named returnValue with an Expression value of @.[User::returnvariable] set to a four-byte signed integer, which (i think) I need to get the value out of the stored procedure.

which points to a

Data Conversion Transformation, which takes care of all the datatype conversions

which points to a

OLE DB Command, which contains the following as the SQL Command:

exec ?= spImportAgencyData ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?

In the OLE DB Command, I have mapped returnValue, my user variable to @.RETURN_VALUE.

Right now, I am in initial testing. The dataflow shows that it is succeeding, but my one data record for testing is not getting inserted. I need to get the value of returnValue to figure out what is happening.

How do I get the value of the returnValue? I have tried putting a recordset destination after the OLE DB command, but that just gives me the data that went into the OLE DB Command.

Thanks,
Kathryn

OK,

I have made a few changes to the package and I can get a return value. The problem is that the data, which is currently only one row in an Excel worksheet, is not getting loaded.

The OLE DB Command's SQL Command is now:

exec spImportAgencyData ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,? output

with the final parameter being an output parameter. On the Column Mappings tab, I have mapped the output parameter @.returnValue which is in the Available Destination Columns to the returnValue variable (in the Available Input Columns) I created earlier in the Derived Column Transformation.

I have added a recordset Destination after the OLE DB Command and I only have the returnValue column in it.

The returnValue is always being returned as 0, which is either because I am not mapping it correctly or because the data is not getting loaded, I'm not sure which.

I can run the stored procedure from SQL Server Management Studio as

DECLARE @.returnValue int

EXEC [dbo].[spImportAgencyData]

@.URN = NULL,

@.FirstName = N'Kathryn',

@........

@.returnValue = @.returnValue OUTPUT

SELECT @.returnValue as N'@.returnValue'

and the correct new ClientID is returned, so the stored procedure is working. I have put a Data Viewer right before the OLE DB Command and run the stored procedure with the exact data coming from the Excel spreadsheet, just to double check and it runs and returns the new Client ID.

Does anyone have any tips on debugging this problem?

Thanks,
Kathryn

|||I had a similar issue (return a value from a stored procedure with 2 Varchar parameters), and eventually this is how I configured the Execute SQL Task:

General:

Connection Type: OLE DB
SQL Statemenet: EXEC ? = AUDIT.LoggingStoredProcedure ?, ?
Bypass Prepare: True

Parameter Mapping:

[Variable Name] | [Direction] | [Data Type] | [Parameter Name]
User::ReturnValue | Return Value | Long | 0
User::Parameter1 | Input | VARCHAR | 1
USer::Parameter2 | Input | VARCHAR | 2