disable passing sp parameter - ssis

I have SSIS package where I have for each loop which runs stored procedures. The loop container passes parameters to the stored procedures. In some cases I need to pass all parameters to stored procedure and in other cases I need to pass only one parameter. Is there any way where I can set if parameter should be passed or not? Maybe will be it possible using Expression in Loop container?

Possibly. Maybe. Probably. As the question stands, it's rather hard to say.
The need is to supply parameters or not based on "logic not supplied in the question." You could have multiple Execute SQL Tasks with a precedence constraint turning powering the different tasks.
An alternative take would be to use an Expression for your query and pass the parameters in as part of the text. I called out some reasons you might not want to do it over on this answer
Yet another approach could be that you null out the parameters in a task where needed as #TI referenced
If you need specifics, please edit your question to contain specifics.

Related

When to return the data or pass in a variable to write the data to

Is there a situation where it's better suited to pass in an existing List to write the data to versus returning a List that may have been instantiated inside the called method?
If your method is subject to interrupts, you may want it to modify an existing list versus returning one. Doing so, you will prevent errors that might occur because an interrupt occurred before the list was returned.

Parameters in MySQL stored procedure

I want to create a MySQL stored procedure (SP) with input parameters.
However, the number of parameters cannot be determined at the time of writing the SP.
(The scenario is that the users will have multiple options to choose. The options chosen will form the search criteria:
select ...
where prod_category = option1 && option2 && option3 &&...
So, if someone chooses only option1 and option2, only 2 parameters will be sent. Sometimes it may be 50+ options are chosen and hence 50+ parameters will have to be sent.)
So, I have 3 questions:
1. Can I handle such a scenario using MySQL stored procedures (SP)?
2. Is the SP the professional way to handle such scenario?
3. If SP is not the professional way to handle these scenarios, is there anything else that will handle these searches efficiently? The search is the core functionality of my application.
Thanks in advance for any help!
MySQL stored procedures accept only a fixed number of arguments. You can build your list of parameters and values delimited on a single string parameter and then process them on your procedure, or use your application language to build the query instead.
From http://forums.mysql.com/read.php?98,154749,155001#msg-155001
No, MySQL sprocs accept only a fixed number of arguments. ISO SQL is
somewhat optimised for correct RDBMS logic (unless you were to ask EF
Codd, CJ Date or Fabian Pascal), but in many ways SQL is quite
literal, so if SQL seems to make what you are trying to do very
difficult, it could be that your design needs another look, in this
case aspects of the design that require repeated multiple ad hoc
deletions.
If such deletions are unavoidable, here are three options. First, in
an application language build the delete query to include
comma-delimited string of IDs. Second, pass such a string to an sproc
that PREPAREs the query using such a string. Third, populate a temp
table with the target IDs and write a simple join query that deletes
the joined IDs.
There are lots of great reasons to use stored procedures. Here's an article that lists some. Hopefully that will address the "professionalism" question.
As for the passing of parameters, I don't believe you can have a variable list.
A long time ago, I saw it "done" by writing the values to a table and having the stored procedure read them back in. (Use a session_id in the table and then pass that to the procedure).
As for "efficiency", it depends on your definition. There might be a slight speed benefit to the stored procedures, but I wouldn't worry about that. What did you mean?

How can I store a query in a MySQL column then subsequently use that query?

For example, say I'm creating a table which stores promo codes for a shipping site. I want to have the table match a promo code with the code's validator, e.g.
PROMO1: Order must have 3 items
PROMO2: Order subtotal must be greater than $50
I would like to store the query and/or routine in a column in the table, and be able to use the content to validate, in the sense of
SELECT * FROM Orders
WHERE Promo.ID = 2 AND Promo.Validation = True
Or something to that effect. Any ideas?
I wouldn't save the query in the database, there are far better possibilities.
You have to decide, which best fits your needs (it's not clear for me based on your question). You can use
Views
or
Prepared Statements
or
Stored Procedures
There's probably a better way to solve the issue, but the answer to your question is to write stored procedures that return the results you want. Where I work (and I hate this design), they actually store all queries and dml used by the application in stored procedures.
You can also dynamically build your queries using dynamic sql. For MySql, see the post below which might be of some help to you.
How To have Dynamic SQL in MySQL Stored Procedure
Otherwise, you can also store your queries in a string format in the database, and retrieve them and execute them using the EXECUTE statement, such as that post points out.
I'd personally keep away from designs like that though. Storing queries in XML isn't a bad alternative, and have your app be written to be extensible and configurable from XML, so you don't need to make code changes to add new validation logic, and instead just have to configure it in XML.

Conditional split based on array variable

I need something like a T-SQL IN statement to filter records in a conditional split based on an array variable (or something similar)
I need to have a list of items that a column can be filtered on.
As Filip has indicated, there is no IN operator in the expression language. I did come up with some options though as I thought this sounded like an interesting problem.
My long analysis is on my blog: Filter list in SSIS
Conditional split
If you can transform your list of values into a delimited string, then you can use FINDSTRING and the current value to determine whether it's in the list. This provided the best throughput for my testing scenario. (FINDSTRING(#[User::MyListStr], [MyColumn],1)) > 0
Script task
I had assumed using a List in a script task to determine membership would provide the best performance but I was wrong. Row.IsInList = MyListObj.Contains(Row.MyColumn);
Lookup/Cache Connection Manager
The third approach I had come up with was dumping the list into a Cached Connection Manager and then using that in a lookup task. I thought this was the easiest to conceptualize and maintain but the performance was lacking.
Conclusion
For this problem domain, the FINDSTRING approach was the most efficient, by a considerable margin. The other three approaches consistently averaged a throughput of within 7 rows per millisecond of each other. I did find it interesting that the standard deviation of the FINDSTRING approach fluctuated so much. While this box is older and slower, there was not a considerable amount of activity going on during the package executions.
There is no IN operator in SSIS expression operators. And there is no similar operator. Since there is no such operator, You can't do that with built-in expressions and built-in Conditional Split. But You can do one of the following:
use Script Transformation to check if particular column has that is in variable array, and add additional column (flag) with value 1 if it contains, 0 if not; then use Conditional Split on this flag added in Script Transformation, or
it's better to put variables in database table and then use Lookup or Merge Join to check if row exists

How do I change the query execution order in SSRS?

How do I control which stored proc runs first in SSRS. My second stored proc needs to use the temp table data from the first stored proc. Thanks so much.
Dataset Execution Order
http://blogs.msdn.com/b/robertbruckner/archive/2008/08/07/dataset-execution-order.aspx
What you are proposing is a significantly bad idea. If both datasets are sharing a table can you merge them into one result set, then filter or aggregate it in the report.
That said, have you tried reordering the datasets in the RDL (XML) file. I imagine reporting service will run these in order, though it may run them asynchronously. No guarantees.
EDIT:
Adolf's Link confirms it, They do run in parallel unless you set Use Single Trasaction in the datasource. Then they run in the order of the RDL file as I suspected.
If you use a value from the first procedure's dataset to be used to populate an input parameter used by the second procedure, this should ensure that they are called in the desired order.
That said, I agree with jimconstable - it would make more sense to use a single dataset and filter out any unwanted results.