Solved

Change flow to detect file exists/not exists

Posted on 2009-05-17
4
375 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
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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Suggested Solutions

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

730 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