![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi: I have had experience doing the following with ActiveX script tasks: 1. Setting the SQL Statement of a data pump task so I can change the WHERE clause before that task executes. 2. Dynamically setting the tablename for tables like MMDDYYYTableName, so the data pump task knows the right table name. Now I need to do this: I'm working with text files and need to set the text file name from an ActiveX task(which I assume will be similar to setting the table name--set the SourceObjectName property of the data pump). The thing is, the task might need to run multiple times depending on how many files I need to read. So here is what should happen: 1. First of all, some info: Data for each one hour interval is stored in a file DDMMYYHHMMTextName.txt. Where HHMM is the beginng of a one hour interval (i.e. 9-10 a.m. is 0900. The DTS package will normally read one of these files each hour just after it is created. But for some reason it might miss reading a file. 2. When package starts, read the newest interval value in my SQL Server table where I am storing previously pumped data. If the time is currently 2:05 p.m., but the newest interval is 09:00, then there must have been a problem before and I want to try to read each interval between then and now. So I establish the files I need and write them to a table for the ActiveX task to use. 050820051000TextName.txt 050820051100TextName.txt 050820051200TextName.txt 050820051300TextName.txt 3. Run the datapump multiple times, passing in a different value for each text file each time. Obviously there will usually only be one text file to read if everything is running smoothly, but there might be more as above. I want to only create one datapump task, but is there a way to run it from an ActiveX script task, so it can run the amount of times I need it to rum, setting the SourceObjectName property (if I'm right and that is what I want to set) each time? Or is there a completely different way to accomplish what I want to accomplish? This will help a lot-I've got my data connections to the text files all set up (and have figure out how to parse these files, which are kind of strange for text files!), if I can figure out the above I will be home free. Thanks a lot, Kayda |
#3
| |||
| |||
|
#4
| |||
| |||
|
|
Hi Alan: I found that article just before you replied, but I'm having problems tailoring it for my needs. What I'm dong is different (not checking directories yet, not using GVs, I've got an extra SQL task in my loop). Here is what I have (2 ActiveX tasks, 2 datapump tasks, 1 source connection(text), 1 Destination(local SQL Server), 1 Execute SQL Task): DTSStep_DTSActiveScriptTask_1 - "Begin Loop" (similar to yours, code below) Text Connection : "AgentContactData" ('Begin Loop' ActiveX sets filename and path of this) DTSStep_DTSDataPumpTask_1 - Dependent on success of DTSStep_DTSActiveScriptTask_1 SQL Server Connection DTSStep_DTSExecuteSQLTask_2: (Cleans up messy text data) Dependent on success of DTSStep_DTSDataPumpTask_1 DTSStep_DTSActiveScriptTask_2 : "Loop Around" (similar to your "Loop Around"). Dependent on success of DTSStep_DTSExecuteSQLTask_2 DTSStep_DTSDataPumpTask_2: What should be executed when loop ends. Dependent on success of DTSStep_DTSActiveScriptTask_1 What happens is the Begin Loop ActiveX runs, setting the textfilename for the pump and supposedly setting the looping properties. The data pump runs, and then the SQL Task runs to clean up some dirty text data (and sets a flag in the database saying I'm done with that last text file I just read). The "Loop Around" ActiveX doesn't run for some reason, and none of the other tasks run. It should have looped around a second time, as there are two text files I am testing on for now. Here is my code for the ActiveX tasks only (I don't think the code of the SQL task is relevant, but let me know if you need this): DTSStep_DTSActiveScriptTask_1 (Begin Loop) Option Explicit Function Main() Dim pkg Dim conTextFile Dim stpEnterLoop Dim stpFinished Dim objconn Dim strSQL Dim FilePath Dim objRS set pkg = DTSGlobalVariables.Parent set stpEnterLoop = pkg.Steps("DTSStep_DTSDataPumpTask_1") set stpFinished = pkg.Steps("DTSStep_DTSDataPumpTask_2") set conTextFile = pkg.Connections("AgentContactData") 'Only if there are values left to write do we want to continue Set objconn = CreateObject("ADODB.Connection") objconn.open = ("provider = sqloledb; data source = (local);user id = sa;password = password") objconn.DefaultDatabase = "CoolDB" strSQL = "SELECT Date_time, Filepath FROM Interval_Update_List " &_ "WHERE Date_time = (SELECT MIN(Date_time) FROM Interval_Update_List " &_ "WHERE AgentContact_Done=0)" Set objRS = objconn.execute(strSQL) IF NOT objRS.EOF then FilePath = objRS.Fields("Filepath") ELSE FilePath = "No_More_Intervals" END IF objRS.Close objconn.Close Set objRS = nothing Set objconn = nothing if FilePath <> "No_More_Intervals" then stpEnterLoop.DisableStep = False stpFinished.DisableStep = True conTextFile.DataSource = FilePath stpEnterLoop.ExecutionStatus = DTSStepExecStat_Waiting else stpEnterLoop.DisableStep =True stpFinished.DisableStep = False stpFinished.ExecutionStatus = DTSStepExecStat_Waiting End if Main = DTSTaskExecResult_Success End Function Main() __________________________________________________ _____ DTSStep_DTSActiveScriptTask_2 (Loop Around) Option Explicit Function Main() Dim pkg Dim stpbegin set pkg = DTSGlobalVariables.Parent set stpbegin = pkg.Steps("DTSStep_DTSActiveScriptTask_1") stpbegin.ExecutionStatus = DTSStepExecStat_Waiting Main = DTSTaskExecResult_Success End Function Main() ________________________________________________ ______________________________________________ Thanks for any help Allan, Kayda |
#5
| |||
| |||
|
#6
| |||
| |||
|
|
Hi Allan: I'm trying to figure this out, and how to apply it to what I've got. The Interval_Update_List table is built at the beginning of the package, containing a field for each 30 minute interval I need, and fields for each of the full paths of various files I'll need for that interval (for each interval there are different files I'll need, but for now I'm just concerned with this one file). So it sounds like you are saying I should built a record set with a select in an SQL task, which is written to a global variable, which I read in my Active X task. A few questions: 1. The global variable showed in the package shows up as type "Dispatch". I cannot see that type to select. 2. How does the SQL task know what variable to write to (I don't see reference to it in the SQL Task)? 3. In your sample there is "Task" acitveX code and "Workflow" code. I'm not sure where the workflow code goes. Thanks, Kayda |
#7
| |||
| |||
|
![]() |
| Thread Tools | |
| Display Modes | |
| |