Solved

Change flow to detect file exists/not exists

Posted on 2009-05-17
4
378 Views
Last Modified: 2013-11-10
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
Comment
Question by:PeterErhard
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 15

Expert Comment

by:MohammedU
ID: 24409150
0
 

Author Comment

by:PeterErhard
ID: 24409643
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
 
LVL 22

Expert Comment

by:PedroCGD
ID: 24410879
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
 
LVL 13

Accepted Solution

by:
TommyTupa earned 500 total points
ID: 24432852
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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
I have a large data set and a SSIS package. How can I load this file in multi threading?
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how the fundamental information of how to create a table.

628 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question