dbTalk Databases Forums  

DTS: How can I process each row in result set to access properties on another package object?

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss DTS: How can I process each row in result set to access properties on another package object? in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
John Peterson
 
Posts: n/a

Default DTS: How can I process each row in result set to access properties on another package object? - 06-05-2004 , 03:38 PM






(SQL Server 2000, SP3a)

Hello all!

I have a DTS package that I'm working with, in which I have a query that I want to invoke
on a target SQL Server that will return a handful of rows. For each row, I want to set
some package properties (on another object in the package). What would be the best
approach to this? I thought that I might use the "Transform Data Task", even though I
don't really have a "Destination", per se (that is, I want to process each "Source" record
via an ActiveX script).

However, when I try and do this, I seem to be getting an error when I execute that
"Transform Data Task" step (something akin to "Execution Cancelled by User").

Is there some other way that I should approach this?

Regards,

John Peterson



Reply With Quote
  #2  
Old   
Dan Guzman
 
Posts: n/a

Default Re: How can I process each row in result set to access properties on another package object? - 06-05-2004 , 05:19 PM






Take a look at the DynamicProperties task. This will allow you to set DTS
properties based query that returns a scalar value. You'll need to specify
a separate query for each property.

--
Hope this helps.

Dan Guzman
SQL Server MVP

"John Peterson" <j0hnp (AT) comcast (DOT) net> wrote

Quote:
(SQL Server 2000, SP3a)

Hello all!

I have a DTS package that I'm working with, in which I have a query that I
want to invoke
on a target SQL Server that will return a handful of rows. For each row,
I want to set
some package properties (on another object in the package). What would be
the best
approach to this? I thought that I might use the "Transform Data Task",
even though I
don't really have a "Destination", per se (that is, I want to process each
"Source" record
via an ActiveX script).

However, when I try and do this, I seem to be getting an error when I
execute that
"Transform Data Task" step (something akin to "Execution Cancelled by
User").

Is there some other way that I should approach this?

Regards,

John Peterson





Reply With Quote
  #3  
Old   
John Peterson
 
Posts: n/a

Default Re: How can I process each row in result set to access properties on another package object? - 06-06-2004 , 12:22 AM



Thanks, Dan -- but I can't seem to get my head around your suggestion. Basically, what I
want is to be able to specify a Source Query that would return a bunch of rows. Then, for
each row, I want to invoke some ActiveX snippet withOUT doing anything to a "Destination".
I don't see that it's too easy with DTS...


"Dan Guzman" <danguzman (AT) nospam-earthlink (DOT) net> wrote

Quote:
Take a look at the DynamicProperties task. This will allow you to set DTS
properties based query that returns a scalar value. You'll need to specify
a separate query for each property.

--
Hope this helps.

Dan Guzman
SQL Server MVP

"John Peterson" <j0hnp (AT) comcast (DOT) net> wrote in message
news:O4WyV0zSEHA.3332 (AT) tk2msftngp13 (DOT) phx.gbl...
(SQL Server 2000, SP3a)

Hello all!

I have a DTS package that I'm working with, in which I have a query that I
want to invoke
on a target SQL Server that will return a handful of rows. For each row,
I want to set
some package properties (on another object in the package). What would be
the best
approach to this? I thought that I might use the "Transform Data Task",
even though I
don't really have a "Destination", per se (that is, I want to process each
"Source" record
via an ActiveX script).

However, when I try and do this, I seem to be getting an error when I
execute that
"Transform Data Task" step (something akin to "Execution Cancelled by
User").

Is there some other way that I should approach this?

Regards,

John Peterson







Reply With Quote
  #4  
Old   
bb_43@hotmail.com
 
Posts: n/a

Default Re: How can I process each row in result set to access properties on another package object? - 06-06-2004 , 03:21 AM



In article <OEs7OZ4SEHA.3852 (AT) TK2MSFTNGP10 (DOT) phx.gbl>, "John Peterson" <j0hnp (AT) comcast (DOT) net> wrote:
Quote:
Thanks, Dan -- but I can't seem to get my head around your suggestion.
Basically, what I
want is to be able to specify a Source Query that would return a bunch of rows.
Then, for
each row, I want to invoke some ActiveX snippet withOUT doing anything to a
"Destination".
I don't see that it's too easy with DTS...

Just do it in a VBScript task.
Open a recordset.
Loop thru it and do whatever you want during each loop.


Reply With Quote
  #5  
Old   
Dan Guzman
 
Posts: n/a

Default Re: How can I process each row in result set to access properties on another package object? - 06-06-2004 , 09:21 AM



Quote:
Thanks, Dan -- but I can't seem to get my head around your suggestion.
Basically, what I
want is to be able to specify a Source Query that would return a bunch of
rows. Then, for
each row, I want to invoke some ActiveX snippet withOUT doing anything to
a "Destination".
I don't see that it's too easy with DTS...
Sorry, but I don't understand what you mean by <withOUT doing anything to a
"Destination">. Please elaborate.

If you want to assign many properties from a single query, below is an
example of the ActiveX script technique suggested by b_43 (AT) hotmail (DOT) com.


CREATE TABLE DTSPackageProperties
(
PackageName varchar(255) NOT NULL,
ObjectName varchar(255) NOT NULL,
PropertyName varchar(255) NOT NULL,
PropertyValue varchar(255) NOT NULL,
)

ALTER TABLE DTSPackageProperties
ADD CONSTRAINT PK_DTSPackageProperties
PRIMARY KEY(PackageName, ObjectName, PropertyName)

INSERT INTO DTSPackageProperties
VALUES('MyPackage', 'MySource', 'DataSource',
'C:\InputFiles\MyInputFile.txt')
INSERT INTO DTSPackageProperties
VALUES('MyPackage', 'MyDestination', 'DataSource',
'C:\OutputFiles\MyOutputFile.txt')

Function Main()
Dim conn, rs, sqlQuery
Set conn = CreateObject("ADODB.Connection")
conn.Open "Provider=SQLOLEDB;" & _
"Data Source=MyServer;" & _
"Integrated Security=SSPI;" & _
"Initial Catalog=MyDatabase"
sqlQuery = "SELECT ObjectName, PropertyValue"
sqlQuery = sqlQuery + " FROM DTSPackageProperties"
sqlQuery = sqlQuery + " WHERE PackageName = '"
sqlQuery = sqlQuery + DTSGlobalVariables.Parent.Name
sqlQuery = sqlQuery + "' AND PropertyName = 'DataSource'"
Set rs = conn.Execute(sqlQuery)
Do While rs.EOF = False

DTSGlobalVariables.Parent.Connections(rs.Fields("O bjectName").Value).DataSou
rce = _
rs.Fields("PropertyValue").Value
rs.MoveNext
Loop
rs.Close
conn.Close
Set rs = Nothing
Set comm = Nothing
Main = DTSTaskExecResult_Success
End Function

The alternative DynamicProperties task method would use the following
queries to assign the properties.

SELECT PropertyValue
FROM DTSPackageProperties
WHERE
PackageName = 'MyPackage' AND
ObjectName = 'MySource' AND
PropertyName = 'DataSource'

SELECT PropertyValue
FROM DTSPackageProperties
WHERE
PackageName = 'MyPackage' AND
ObjectName = 'MyDestination' AND
PropertyName = 'DataSource'

--
Hope this helps.

Dan Guzman
SQL Server MVP

"John Peterson" <j0hnp (AT) comcast (DOT) net> wrote

Quote:
Thanks, Dan -- but I can't seem to get my head around your suggestion.
Basically, what I
want is to be able to specify a Source Query that would return a bunch of
rows. Then, for
each row, I want to invoke some ActiveX snippet withOUT doing anything to
a "Destination".
I don't see that it's too easy with DTS...


"Dan Guzman" <danguzman (AT) nospam-earthlink (DOT) net> wrote in message
news:u8ri%23s0SEHA.3608 (AT) TK2MSFTNGP11 (DOT) phx.gbl...
Take a look at the DynamicProperties task. This will allow you to set
DTS
properties based query that returns a scalar value. You'll need to
specify
a separate query for each property.

--
Hope this helps.

Dan Guzman
SQL Server MVP

"John Peterson" <j0hnp (AT) comcast (DOT) net> wrote in message
news:O4WyV0zSEHA.3332 (AT) tk2msftngp13 (DOT) phx.gbl...
(SQL Server 2000, SP3a)

Hello all!

I have a DTS package that I'm working with, in which I have a query
that I
want to invoke
on a target SQL Server that will return a handful of rows. For each
row,
I want to set
some package properties (on another object in the package). What
would be
the best
approach to this? I thought that I might use the "Transform Data
Task",
even though I
don't really have a "Destination", per se (that is, I want to process
each
"Source" record
via an ActiveX script).

However, when I try and do this, I seem to be getting an error when I
execute that
"Transform Data Task" step (something akin to "Execution Cancelled by
User").

Is there some other way that I should approach this?

Regards,

John Peterson









Reply With Quote
  #6  
Old   
John Peterson
 
Posts: n/a

Default Re: How can I process each row in result set to access properties on another package object? - 06-06-2004 , 12:50 PM



Thanks Dan (and bb_43)!

I had hoped there would have been a simpler solution in the context of existing DTS
objects, rather than having to write a lot of code. Alas, it seems like it's not quite
the case, even though DTS seems uniquely qualified to do this type of thing (almost).
Since it can use a Connection to issue a query on that remote server and process the rows.
The only problem is that both the "Transform Data Task" and "Data Driven Query Task" seem
to *require* a "destination" object; that you can't simply have an ActiveX transformation
script for each row without having the data ultimately going somewhere.

Thanks again!

John Peterson



"Dan Guzman" <danguzman (AT) nospam-earthlink (DOT) net> wrote

Quote:
Thanks, Dan -- but I can't seem to get my head around your suggestion.
Basically, what I
want is to be able to specify a Source Query that would return a bunch of
rows. Then, for
each row, I want to invoke some ActiveX snippet withOUT doing anything to
a "Destination".
I don't see that it's too easy with DTS...

Sorry, but I don't understand what you mean by <withOUT doing anything to a
"Destination">. Please elaborate.

If you want to assign many properties from a single query, below is an
example of the ActiveX script technique suggested by b_43 (AT) hotmail (DOT) com.


CREATE TABLE DTSPackageProperties
(
PackageName varchar(255) NOT NULL,
ObjectName varchar(255) NOT NULL,
PropertyName varchar(255) NOT NULL,
PropertyValue varchar(255) NOT NULL,
)

ALTER TABLE DTSPackageProperties
ADD CONSTRAINT PK_DTSPackageProperties
PRIMARY KEY(PackageName, ObjectName, PropertyName)

INSERT INTO DTSPackageProperties
VALUES('MyPackage', 'MySource', 'DataSource',
'C:\InputFiles\MyInputFile.txt')
INSERT INTO DTSPackageProperties
VALUES('MyPackage', 'MyDestination', 'DataSource',
'C:\OutputFiles\MyOutputFile.txt')

Function Main()
Dim conn, rs, sqlQuery
Set conn = CreateObject("ADODB.Connection")
conn.Open "Provider=SQLOLEDB;" & _
"Data Source=MyServer;" & _
"Integrated Security=SSPI;" & _
"Initial Catalog=MyDatabase"
sqlQuery = "SELECT ObjectName, PropertyValue"
sqlQuery = sqlQuery + " FROM DTSPackageProperties"
sqlQuery = sqlQuery + " WHERE PackageName = '"
sqlQuery = sqlQuery + DTSGlobalVariables.Parent.Name
sqlQuery = sqlQuery + "' AND PropertyName = 'DataSource'"
Set rs = conn.Execute(sqlQuery)
Do While rs.EOF = False

DTSGlobalVariables.Parent.Connections(rs.Fields("O bjectName").Value).DataSou
rce = _
rs.Fields("PropertyValue").Value
rs.MoveNext
Loop
rs.Close
conn.Close
Set rs = Nothing
Set comm = Nothing
Main = DTSTaskExecResult_Success
End Function

The alternative DynamicProperties task method would use the following
queries to assign the properties.

SELECT PropertyValue
FROM DTSPackageProperties
WHERE
PackageName = 'MyPackage' AND
ObjectName = 'MySource' AND
PropertyName = 'DataSource'

SELECT PropertyValue
FROM DTSPackageProperties
WHERE
PackageName = 'MyPackage' AND
ObjectName = 'MyDestination' AND
PropertyName = 'DataSource'

--
Hope this helps.

Dan Guzman
SQL Server MVP

"John Peterson" <j0hnp (AT) comcast (DOT) net> wrote in message
news:OEs7OZ4SEHA.3852 (AT) TK2MSFTNGP10 (DOT) phx.gbl...
Thanks, Dan -- but I can't seem to get my head around your suggestion.
Basically, what I
want is to be able to specify a Source Query that would return a bunch of
rows. Then, for
each row, I want to invoke some ActiveX snippet withOUT doing anything to
a "Destination".
I don't see that it's too easy with DTS...


"Dan Guzman" <danguzman (AT) nospam-earthlink (DOT) net> wrote in message
news:u8ri%23s0SEHA.3608 (AT) TK2MSFTNGP11 (DOT) phx.gbl...
Take a look at the DynamicProperties task. This will allow you to set
DTS
properties based query that returns a scalar value. You'll need to
specify
a separate query for each property.

--
Hope this helps.

Dan Guzman
SQL Server MVP

"John Peterson" <j0hnp (AT) comcast (DOT) net> wrote in message
news:O4WyV0zSEHA.3332 (AT) tk2msftngp13 (DOT) phx.gbl...
(SQL Server 2000, SP3a)

Hello all!

I have a DTS package that I'm working with, in which I have a query
that I
want to invoke
on a target SQL Server that will return a handful of rows. For each
row,
I want to set
some package properties (on another object in the package). What
would be
the best
approach to this? I thought that I might use the "Transform Data
Task",
even though I
don't really have a "Destination", per se (that is, I want to process
each
"Source" record
via an ActiveX script).

However, when I try and do this, I seem to be getting an error when I
execute that
"Transform Data Task" step (something akin to "Execution Cancelled by
User").

Is there some other way that I should approach this?

Regards,

John Peterson











Reply With Quote
  #7  
Old   
Paul Ibison
 
Posts: n/a

Default Re: How can I process each row in result set to access properties on another package object? - 06-06-2004 , 02:32 PM



John,
if you do want to use the Transform Data Task without inserting rows you can
change the DTSTransformStatus constant from DTSTransformStat_OK to
DTSTransformStat_SkipInsert.
HTH,
Paul Ibison



Reply With Quote
  #8  
Old   
John Peterson
 
Posts: n/a

Default Re: How can I process each row in result set to access properties on another package object? - 06-06-2004 , 04:53 PM



<blush> I did not know such a return value existed! Thanks so much, Paul -- I'm sure
that'll do the trick! (And I think you pegged my issue *exactly*!)


"Paul Ibison" <Paul.Ibison (AT) Pygmalion (DOT) Com> wrote

Quote:
John,
if you do want to use the Transform Data Task without inserting rows you can
change the DTSTransformStatus constant from DTSTransformStat_OK to
DTSTransformStat_SkipInsert.
HTH,
Paul Ibison





Reply With Quote
  #9  
Old   
Paul Ibison
 
Posts: n/a

Default Re: How can I process each row in result set to access properties on another package object? - 06-07-2004 , 02:48 AM



No problem. FYI I came across this info from this book which is the most
comprehensive DTS book I know of:
http://www.amazon.co.uk/exec/obidos/...145180-8774263
Regards,
Paul Ibison



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.