Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 382
  • Last Modified:

Change flow to detect file exists/not exists

I have the following flow (see attached) which works fine, there are two import files named:

Suppliers.xml
Jobseekers.xls

The problem comes if one of these files don't exist in the directory, it fails.

I need the flow to be able to detect if only Suppliers.xml exists only run the Process Suppliers,
and if Jobseekers.xls exists only run that, but if both exist run everything.

Does anyone know how I could look at doing that?
flow.JPG
0
PeterErhard
Asked:
PeterErhard
1 Solution
 
PeterErhardAuthor Commented:
Thanks Mohammed, but the 1st link is for the same data-type. I have two different data-types.

And the 2nd link is for a third party control, and I can't use third party controls.
0
 
PedroCGDCommented:
Check the document I made inthis link and give feedback
http://biresort.net/blogs/pedrocgd/archive/2009/05/14/stepbystep-ssis-moving-huge-amount-of-files.aspx
helped?
regards,
Pedro
0
 
TommyTupaCommented:
My workaround is to simply create two configuration variables and then use the precedence contraint editor for the workflow based on the variables.

1. Setting the variables
This can be done before package execution or within a script task.  I set a configuration variable before running the package with a job step containing a script like this, then when the package executes its variables are automatically set to the configuration variable.
------------
--File Files in Directory
Declare @cmd varchar(2000),
@SourcePath varchar(200),
@Filexls int,
@Filexml int

SET QUOTED_IDENTIFIER OFF

Set @SourcePath = 'C:\Apps\Test\'
Select @Cmd ="master.dbo.XP_CMDSHELL 'dir /B " + @SourcePath + "'"

begin try drop table ##tFiles; end try begin catch end catch;

Create Table ##tFiles
(RowID int Identity,
FileName varchar(100),
FileType varchar(3)
)

INSERT ##tFiles (FileName)
EXEC(@CMD)

Update ##tFiles
set FileType = right(FileName,3)

SELECT
@FileXML =
MAX(CASE WHEN FileType = 'xml' THEN 1 ELSE 0 END),
@FileXLS =
MAX(CASE WHEN Filetype = 'xls' THEN 1 ELSE 0 END)
FROM
 ##tFiles

--Update Configuration Table
Update SSISConfig
Set ConfiguredValue =
CASE @FileXML WHEN 1 THEN 'True' ELSE 'False' END
Where ConfigurationFilter = 'Suppliers'

Update SSISConfig
Set ConfiguredValue =
CASE @FileXLS WHEN 1 THEN 'True' ELSE 'False' END
Where ConfigurationFilter = 'JobSeekers'
--------------------------------



2. Set The Precedence Constraint to the variable expression.
After your Process Temp data flow break off the rest of your steps into two branches paths; one for suppliers and one for jobseekers. So you'll end up with two arrows originating from Process Temp.


Double-click the arrow to Process Suppliers and set the constraint to evaluate to an expression such as
@[User::Suppliers]=="True".  Double-click the arrow going to ProcessJobSeekers and similarly set an expression such as @[User::JobSeekers]=="True"
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now