InMemory ETL task: While

The 'While' task is a container that will execute the contained tasks in a loop as long as the criteria for looping is fulfilled.

The While task's properties can work with two condition types:

  • Table
    • With the 'Table' condition type, you will also need to supply the name of a table (in the Table property) that has been imported prior to the While task.
    • The While task will keep looping until EOF (End Of File), i.e., until all records in the table have been looped.
  • Condition
    • With the 'Condition' condition type, you will also need to supply a condition (in the Condition property).
    • The condition can be any logical expression, e.g., @Count > 0.

 

Example with Condition type = Table

DECLARE @PathName as string
IMPORT [FileList] = [FileList].{SELECT * FROM [C:\Temp\CSVdata\DailyData]
WHERE filename='*.csv' AND directory='current'}
WHILE [FileList].EOF=false
SET @PathName = [FileList].[fullpath]
IMPORT [CombinedCSVTable] = [CSV].{SELECT * FROM [@@PathName]}
  MOVENEXT [FileList]
LOOP
SAVE

 

Example with Condition type = Condition

DECLARE @Count as int
SET @Count=10
CREATE TABLE [CountTable] (CountField int)
WHILE @Count>0
INSERT INTO [CountTable] (CountField) VALUES (@Count)
SET @Count=@Count-1
LOOP
SAVE
Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.