![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
|
I am in dire need of assistance and have spent days going through articles and forum posts. I have a DTS package that exports data to one or more text files based on a table query. The package starts with an SQL Execute task that returns a rowset as a global variable. The next task, that executes on successful completion of the SQL execute task, is an ActiveX script task that extracts global variable values that are used as input parameters to the query that the Data Transformation task uses next. In addition, each text file that is exported has a unique file name that is created at runtime using the global variable information. The first ActiveX script generates/assigns the first file name and the input parameters for the data transformation task. The first text file exported is perfect. The task that bombs on me is the second ActiveX script that follows the Data Transformation step. This second ActiveX script is supposed to generate the remaining text files by placing the Data transformation task in a waiting state. All of the remaining text files are named and generated, but are empty. I know that there is valid data to export for these files because I tested the data transform for each set of inputs. Following is a copy of my 2nd ActiveX script. Please help me to understand why this isn't working. I'm new to both vbscript and DTS, so forgive my obvious ignorance: ' Visual Basic ActiveX Script '************************************************* *********************- ** Option Explicit Dim ado_mdsql_Connect Dim strConnect_mdsql Dim objresults Function Main() Dim oPKG Dim osrcConnection Dim odestConnection Dim fsObject, sourcefile, destinationfile, fsTextFile Dim cntr set ado_mdsql_Connect = CreateObject("ADODB.Connection") strConnect_mdsql = "Provider=SQLOLEDB;" & "Driver={SQL Server};" & "Server=SERVER- MD1;" & "Database=MDSQL;" & "Trusted_Connection=yes" ado_mdsql_Connect.Open strConnect_mdsql set objresults = CreateObject("ADODB.recordset") Set objresults = DTSGlobalVariables("glbv_cust_invoice_nbrs").Value Do until objresults.EOF Set oPKG = DTSGlobalVariables.Parent Set osrcConnection = oPKG.Connections("MDSQL Source") objresults.MoveNext If objresults.EOF then DTSGlobalVariables("glbv_customer_nbr").Value = "" DTSGlobalVariables("glbv_invoice_date").Value = "" DTSGlobalVariables("glbv_invoice_nbr").Value ="" Main = DTSStepExecStat_Completed else DTSGlobalVariables("glbv_customer_nbr").Value = objresults("Cust_No").Value DTSGlobalVariables("glbv_invoice_nbr").Value = objresults("Invoice_#").Value DTSGlobalVariables("glbv_invoice_date").Value = objresults("Inv_Date").Value Set fsObject = CreateObject("Scripting.FileSystemObject") destinationfile = "\\server- md1\Raid5\Inetpub\ftproot\StoreEDI\"&objresults("C ust_No").Value&"i"&Ri- ght(objresults("Invoice_#").Value,3)&".txt" Set fsTextFile = fsObject.CreateTextFile(destinationfile,True) fsTextFile.Close Set fsObject = nothing Set odestConnection = oPKG.Connections("Destination") odestConnection.DataSource = destinationfile DTSGlobalVariables("glbv_txtfile_path_and_name").V alue = destinationfile oPKG.Steps("DTSStep_DTSDataPumpTask_1").ExecutionS tatus= DTSStepExecStat_Waiting end if loop Main = DTSTaskExecResult_Success End Function Also, Many thanks to Darren Green for his articles on SQLDTS. They were very helpful. -- Posted via http://dbforums.com |
#2
| |||
| |||
|
#3
| |||
| |||
|
|
I'm overwhelmed by the level of assistance you have provided. It never occurred to me to use an array. I will give this a try. Thanks!!! |
#4
| |||
| |||
|
|
In article <3324249.1062598318 (AT) dbforums (DOT) com>, roxindigo member37650 (AT) dbforums (DOT) com> writes I'm overwhelmed by the level of assistance you have provided. It never occurred to me to use an array. I will give this a try. Thanks!!! I think an array is making hard work of the job, especially as an array can be a pain itself due to the strange type it uses and the fact that the package cannot be saved in this state. You can use the recordset object directly to drive a loop, and to save messing around with ADO I would use the Execute SQL Task to get the RS object into a global variable. The script confused me, since you appeared to do objresults.MoveNext before reading any values, which means you will always miss the first row. You also set a step to waiting, but then continued with the loop, so it wouldn't get a chance to execute. I may have misread this however. If you want a nice sample of driving a loop of tasks from a SQL recordset query then let me know and I'll mail it direct. I never got round to writing it up for the site, but I will. If however you are happy with your arrays then just ignore this and stick with what works for now. -- Darren Green (SQL Server MVP) DTS - http://www.sqldts.com |
#5
| |||
| |||
|
#6
| |||
| |||
|
#7
| |||
| |||
|
#8
| |||
| |||
|
|
Hello, I read and looked at Darren's article "How to loop through a global variable Rowset". I have a little different need. I need to get a subset of data from a production server to a development server. The data is relative based on a colum 'CFcKey'. I gathered 20,000 records out of the primary table and want to use the pkey to gather the related (n) records from a secondary table on the production server then send the result into the sister table on the development server. I can think of sending the result sets to files then uploading the file into the development server. Can anybody think of a way to skip the 'sending results to a file' step and get the data from Prod to Dev? Any assistance is greatly appreciated, I am bout whipped! Thanks Bill *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
#9
| |||
| |||
|
#10
| |||
| |||
|
|
There are two servers, A (Production) B (Development). Server A's primary table has well over 5 million records, with multiple related records in each of the other 9 tables. I want to get about 20,000 of the primary tables records, then only the related records from the other 9 tables from server A to B. I was attempting to use a DTS package to faciliate the data moving processes. *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
![]() |
| Thread Tools | |
| Display Modes | |
| |