Showing posts with label task. Show all posts
Showing posts with label task. Show all posts

Friday, March 30, 2012

no luck w/ execute sql task and assigning variable

Hello,

I've asked this question before and I've read the answers before and I still cannot get it to work. My task is simple, I want to use the execute sql task container to grab a value from a database and put it in a variable. I've done all the preliminary stuff such as running profiler to make sure that the package is getting the call to the database, setting up the ResultSet to be "single row" in the general tab, mapped the Result Set correctly, but nothing works. I get the same error every time.

This is my sql command:

select output_location as output_location
from script_master

Result Set is set up like this:

Result Name: output_location ; Variable Name: User::output_location

Here is the error I get:

Error: 0xC002F309 at Execute SQL Task, Execute SQL Task: An error occurred while assigning a value to variable "output_location": "The type of the value being assigned to variable "User::output_location" differs from the current variable type. Variables may not change type during execution. Variable types are strict, except for variables of type Object.

".

I don't know what I'm doing wrong, I've followed all the instructions exactly on how to populate a variable in this container. My variable is set up as a string, if I change it to object I can get it to work. I think this is because the object is allowing nulls. I really believe that the variable is not populating and that is why I'm getting errors.

Please help. If you could provide step by step example's that would really make my day.

Thanks,

Phil

First, your result set name should be "0".
Second, does your query return more than one row? If not, make sure that your result set is set to "single row." If your query returns more than one row, then you'll need to make sure User::output_location is an OBJECT datatype. If you only have one row being returned, then User::output_location can be set to the datatype of the query returned value.|||

How many rows does the query retreive? are you sure?

What is the data type of the column you are trying to query?

What is the data type of Variable?

|||Hi Phil,

You can modify your select statement to handle nulls:

select ISNULL(output_location,'') as output_location
from script_master

I partly disagree with Phil (Brammer) that you should set the Result set name to "0". That depends... if you're using an ADO.NET connection manager "0" would work but if you're using an OLEDb connection manager then the column name of the result (in this case, "output_location") should be used.|||

I just played around with this some more. I made the sql statement:

select count(output_location) as output_location

from script_master

and the result is 1. I also changed the variable to int16 and IT WORKED!! But, alas, that's not what I want I actually want the value of output_location which is a nvarchar column in the database. As soon as I changed the variable from int16 back to string and changed count(output_location) back to just output_location, I got the same error as before.

Could it have anything to do with my result of output_location is returning a string like this:

\\usilchfp01\userdata\ptackett\SSIS\test.xls

Thanks for the quick replies,
Phil

|||

Jon Limjap wrote:

Hi Phil,

You can modify your select statement to handle nulls:

select ISNULL(output_location,'') as output_location
from script_master

I partly disagree with Phil (Brammer) that you should set the Result set name to "0". That depends... if you're using an ADO.NET connection manager "0" would work but if you're using an OLEDb connection manager then the column name of the result (in this case, "output_location") should be used.

OLE DB uses numeric parameter names. You have that backwards, but the point is still valid.|||

tackett wrote:

Could it have anything to do with my result of output_location is returning a string like this:

\\usilchfp01\userdata\ptackett\SSIS\test.xls

Hmmm, not sure. Perhaps you can chnage the value in the table to a more simple and test it.

|||

Ok, I tried the:

select isnull(output_location,'') as output_location

from script_master

Same result.

I also tried it with a where clause, figuring it didn't like the fact I didn't have one before:

select isnull(output_location,'') as output_location

from script_master

where 1 = 1

That also didn't work.

I've tried using the "0" as the result name as well as "output_location" both do not work.

I appreciate the feedback so far. Any other ideas?

Thanks,

Phil

|||Oops sorry didn't see the post above.

I think the \\ might be wrecking the variable somehow. Strings in SSIS use C-style escaping, so having backslashes allover the place might be emitting some illegal escape characters of some sort. That's just a guess.

You might want to try this approach: assign another variable as an object to the Result of your query. Then have your original string variable's EvaluateExpression property set to True. In the expression cast the object to a string with the expression "<DT_STR 30,1252> @.[User::objOutputLocation]"

(I'm not sure with the property name and the expression... I'm not on my SSIS machine right now)|||

I just updated it from to be:

update script_master

set output_location = 'try this'

so it's now "try this" as a string. But that didn't work either.

Phil

|||

tackett wrote:

I just updated it from to be:

update script_master

set output_location = 'try this'

so it's now "try this" as a string. But that didn't work either.

Phil

What's the column type of output_location? varchar? nvarchar?|||nvarchar|||nvarchar(max) actually|||

Well, I just figured it out. I changed my column from nvarchar(max) to nvarchar(500) and it works fine. What the *&^$? It also works if the column is nvarchar(max) and you cast or convert it along the way. Oh well, I learned this the hard way.

Thanks,

Phil

|||Ouch. I think that's it. It's possible that SSIS strings don't handle unicode strings that are that wide (specifically because nvarchars are twice the size of varchars).

If you can try to narrow your nvarchar definition (perhaps nvarchar(2000) would suffice) then try again, I think the problem will be solved. Otherwise you can try out what I posted above (the one that uses expressions).

HTHsql

No loading data from ScriptComponent.

Dear all,

I've created a Data Flow scenario as follow:

At first I've got a Flat File Source and then Script Component Task and then OleDb Destination, linked among them by arrows, of course. When I run the SSIS all of them is successfully executed except the last task. Why? I don't know but it isn't awared of nothing.

649 rows are passed to Script Component from the file but they aren't going to my Sql table.

Let me know any advice or thought regarding ths.

Thanks a lot,

We need far far more information than you have provided here.

Is it a synchronous or asynchronous compoennt?|||

Hi Jamie,

Thanks for your quick response.

You'll see the full contains for the .net script

Public Class ScriptMain

Inherits UserComponent

Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)

Dim valorColumna As String

valorColumna = Row.Column9.Substring(1, 1)

If valorColumna = "N" Then

Me.Output0Buffer.IMPBASE = -1 * CDbl(Row.Column10 / 100)

Else

Me.Output0Buffer.IMPBASE = CDbl(Row.Column10 / 100)

End If

Me.Output0Buffer.PORCRETEN = CDbl(Row.Column11 / 100)

Me.Output0Buffer.IMPRETEN = CDbl(Row.Column12 / 100)

Me.Output0Buffer.EJERCICIO = CInt(Row.Column2)

Me.Output0Buffer.CODPROV = CInt(Row.Column7)

Me.Output0Buffer.MODALIDAD = CInt(Row.Column8)

Me.Output0Buffer.NIFPERC = CStr(Row.Column3)

Me.Output0Buffer.NIFREP = CStr(Row.Column4)

Me.Output0Buffer.NOMBRE = CStr(Row.Column6)

Me.Output0Buffer.EJERDEV = CDbl(Row.Column13)

End Sub

I haven't idea if it's asyn or syn

I think that there is some big error very very stupid in all of this.

Thanks again,

Enric

Monday, March 26, 2012

No Debugging and logging when a single script task is executed

Hi,

I cannot execute a script task in the VBA code window.

I cannot debug or log if I run a single script task from the right click Execute Task .

Every time I have to run the entire package in order to be able to debug.

What am I missing?

appreciate a help.

Gulden

try disabling all the other tasks and/or containers except the script task. then, execute the package.

|||Thank You.. I guess it is the only way..|||

Gulden wrote:

Thank You.. I guess it is the only way..

If memory serves correctly, yes, it IS the only way.

We hope this will change in the future. It certainly SHOULD be changed!

-Jamie

Wednesday, March 21, 2012

No ADO type command for Data Flow?

I'm probably not looking in the right place, but all I could find when creating a data flow task was OLE DB Commands. I was trying to utilize a dataaccesslayer piece of code that we use every where in our projects, but because it uses ADO and not OLE DB, it caused an issue between the column data types.

Is there an ADO command object available? Or are we forced to use the OLE DB command object? All I was looking to do was to Execute a SQL command. There's an object on the Control Flow level to do that, but not on the Data Flow levelnot sure why that is.

Thanks,

Jeff Tolman
E&M Electric

Its because executing a stand-alone SQL statement isn't relevant for a data-flow. As you have observed you can do that in the Execute SQL Task.

What exactly is it that you want to do? What is your SQL statement?

-Jamie

|||

You would only use the data flow task if you wanted to process many rows of data - either aggregating them to pass them to your command, or issuing the command for every row that passes.

If you have existing code, you can likely acheive that using the Script Component - but be sure your scenario is appropriate first.

Can you describe some more about what you are trying to acheive?

Donald

|||

It's not necessarily a particular command. It's using ADO vs. OLE DB. Our DataAccessLayer code uses ADO, which I was able to import into the VSA scripting editor and that seemed to work just fine. However the output of the Script Component feeds records to separate SQL commands, but the only thing that I see that's available is the OLE DB Command. I know I could probably do this within the Script component, but it just seems to be more logically designed and layed out this way.

Thanks,

Jeff

|||

I have a set of records coming in to a Script Component and based on the data and lookups into the destination table I'm determining if data should be deleted, inserted or updated in the destination table. It's basically a table copy routine with a little intelligence for deletes.

Jeff

|||

JazzGeek wrote:

It's not necessarily a particular command. It's using ADO vs. OLE DB. Our DataAccessLayer code uses ADO, which I was able to import into the VSA scripting editor and that seemed to work just fine. However the output of the Script Component feeds records to separate SQL commands, but the only thing that I see that's available is the OLE DB Command. I know I could probably do this within the Script component, but it just seems to be more logically designed and layed out this way.

Thanks,

Jeff

Sorry, I'm really really confused. In SSIS you don't access data using the OLE DB Command component. You do it with a source adapter. There are many source adapters including one for OLE DB and one for ADO.

Are you saying that you want apply modifications using ADO rather than OLE DB?

-Jamie

|||

Hey Jamie,

I was just hoping to use our DataAccessLayer code library (which utilized ADO) to perform DB commands against our databases. I realize that with the OLE DB Command object you can execute a SQL command based on any of the input column data. Since I couldn't find an ADO Command object, I thought I'd use our DataAccessLayer library within a Script component to do it.

Thanks for the comments!

Jeff