p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   SQL Server DTS (http://p2p.wrox.com/forumdisplay.php?f=108)
-   -   DTS Problem with ActiveX Script (http://p2p.wrox.com/showthread.php?t=36408)

testsubject December 23rd, 2005 09:29 AM

DTS Problem with ActiveX Script
 
Hi folks,

I have a slight problem.

The below code is for the ActiveXScript which is used for the Data Transformation:

Code:

Function Main()

dim arrname

DTSDestination("IHEDAT")=DTSSource("EDDT")
'DTSDestination("ADDIMS")=DTSSource("HLFL")
DTSDestination("IHRELG")=DTSSource("RELG") 

arrname = DTSLookups("lk_epg_eve").Execute(DTSSource("PKEY"),DTSSource("ADDT"))

If IsEmpty(arrname) Then   

                        'MsgBox(DTSSource("PKEY"))

                        'MsgBox(DTSSource("ADDT"))

 

            arrname = DTSLookups("lk_MAT_AD").Execute(DTSSource("PKEY"),DTSSource("ADDT"))

             If IsEmpty(arrname) Then

            Else

                        DTSDestination("IHMROL") = arrname(0)

                        DTSDestination("IHROLL") = arrname(1)

                        DTSDestination("IHADAT") = arrname(2)

                        DTSDestination("IHATIM") = arrname(3)

                        DTSDestination("IHAFLG") = arrname(4)

                        DTSDestination("IHCCON") = arrname(5)

                        DTSDestination("IHCSPC") = arrname(6)

                        DTSDestination("IHWLKY") = arrname(7)

                        DTSDestination("IHTDAT") = arrname(8)

                        DTSDestination("IHTTIM") = arrname(9)

                        DTSDestination("IHPMAN") = arrname(10)

                        DTSDestination("IHSORC") = arrname(11)

                        DTSDestination("IHMETH") = arrname(12)

                        DTSDestination("IHDMET") = arrname(13)

                        DTSDestination("IHDDST") = arrname(14)

                        DTSDestination("IHDDAT") = arrname(15)

                        DTSDestination("IHDTIM") = arrname(16)

                        DTSDestination("IHACAT") = arrname(17)

                        DTSDestination("IHWARD") = arrname(18)

                        DTSDestination("ADDIMS") = arrname(19)

            End If

Else

            'MsgBox(DTSSource("PKEY"))

            DTSDestination("IHMROL") = arrname(0)

            DTSDestination("IHROLL") = arrname(1)

            DTSDestination("IHADAT") = arrname(2)

            DTSDestination("IHATIM") = arrname(3)

            DTSDestination("IHAFLG") = arrname(4)

            DTSDestination("IHCCON") = arrname(5)

            DTSDestination("IHCSPC") = arrname(6)

            DTSDestination("IHWLKY") = arrname(7)

            DTSDestination("IHTDAT") = arrname(8)

            DTSDestination("IHTTIM") = arrname(9)

            DTSDestination("IHPMAN") = arrname(10)

            DTSDestination("IHSORC") = arrname(11)

            DTSDestination("IHMETH") = arrname(12)

            DTSDestination("IHDMET") = arrname(13)

            DTSDestination("IHDDST") = arrname(14)

            DTSDestination("IHDDAT") = arrname(15)

            DTSDestination("IHDTIM") = arrname(16)

            DTSDestination("IHACAT") = arrname(17)

            DTSDestination("IHWARD") = arrname(18)

            DTSDestination("ADDIMS") = arrname(19)

End If

Main = DTSTransformStat_OK

End Function

This code is for the lk_epg_eve lookup

Code:

SELECT    HSPPROG.EPG.PKEY, HSPPROG.EPG.EPSD, HSPPROG.EPG.ADDT, HSPPROG.EPG.ADTM, HSPPROG.EVE.EVT, HSPPROG.EPG.CONS,
                      HSPPROG.EPG.SPCD, HSPPROG.EPG.WKEY, HSPPROG.EVE."DATE", HSPPROG.EVE."TIME", HSPPROG.EPG.INTN, HSPPROG.EPG.ADSC,
                      HSPPROG.EPG.ADMT, HSPPROG.EPG.DSMT, HSPPROG.EPG.DSDS, HSPPROG.EPG.EPEN, HSPPROG.EPG.EETM, HSPPROG.EPG.STAT,
                      HSPPROG.EVE.TWHE, HSPPROG.EVE.CHR1
FROM        HSPPROG.EPG, HSPPROG.EVE
WHERE    HSPPROG.EPG.PKEY = HSPPROG.EVE.PKEY AND HSPPROG.EPG.EPSD = HSPPROG.EVE.EPSD AND (HSPPROG.EVE.EVT IN ('AD', 'TR', 'DS', 'HM'))
                      AND (HSPPROG.EVE.MODU = 'INP') AND (HSPPROG.EPG.PKEY = ?) AND (HSPPROG.EPG.ADDT = ?)

This code is for the lk_MAT_AD lookup:

Code:

SELECT    HSPPROG.EPG.PKEY, HSPPROG.EPG.EPSD, HSPPROG.EPG.ADDT, HSPPROG.EPG.ADTM, HSPPROG.EVE.EVT, HSPPROG.EPG.CONS,
                      HSPPROG.EPG.SPCD, HSPPROG.EPG.WKEY, HSPPROG.EVE."DATE", HSPPROG.EVE."TIME", HSPPROG.EPG.INTN, HSPPROG.EPG.ADSC,
                      HSPPROG.EPG.ADMT, HSPPROG.EPG.DSMT, HSPPROG.EPG.DSDS, HSPPROG.EPG.EPEN, HSPPROG.EPG.EETM, HSPPROG.EPG.STAT,
                      HSPPROG.EVE.TWHE, HSPPROG.EVE.CHR1
FROM        HSPPROG.EPG, HSPPROG.EVE
WHERE    HSPPROG.EPG.PKEY = HSPPROG.EVE.PKEY AND HSPPROG.EPG.EPSD = HSPPROG.EVE.EPSD AND (HSPPROG.EVE.EVT = 'AD') AND
                      (HSPPROG.EVE.MODU = 'MAT') AND (HSPPROG.EPG.PKEY = ?) AND (HSPPROG.EPG.ADDT = ?)

It sends two values PKEY and ADDT to two lookups which return and population the fields in the array. Now this is find and great but it is only populating one instance for PKEY and ADDT, where as PKEY and ADDT can be the same but the ENT can be different.

In other words i need the DTS to write the other instances of the same PKEY and ADDT until the end of all the instances, and then move onto the next PKEY and ADDT.

Hope this makes sense, and any help would be gratful.

Thanks

David_the_DBA December 23rd, 2005 05:11 PM

TestSubject:

You said you hope that your post makes sense, and since I can get the general feel for what you are doing, even if I can't make sense of the details I am going to recommend an alternate approach.

Rather than trying to a complicated transform I find it easier to setup a staging table (identical structure to the source table) in the destination database. Then Use the Data Pump Task to Pump the data into the staging table without transforms, but using the criteria in a where clause to limit the data. Then once you have the data in your staging table you can do joins to your lookup tables and accomplish your transformations using an insert select statement instead of a data pump task.

David Lundell
Principal Consultant and Trainer
www.mutuallybeneficial.com


All times are GMT -4. The time now is 02:05 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.