[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.8

How do I gather/pass multiple input parameters to SQL stored procedure?

Asked by MTaft in Crystal Reports Software, SQL Server 2005

Tags: input parameters, stored procedure

Hello Experts,

I am writing a Crystal Report (in CRXI) that will explode the Bill of Materials for each part number entered by the user.  Additionally, the user wants to be able to prioritize the list of part numbers, and to enter a Build Quantity for each part number as well.

So my input parameters need to accommodate something like this:

Priority    PartNo     BuildQty
---------    -----------  ----------
2             m123        3
1             m234        2
3             m111        4

And then I need to feed the SQL stored procedure these values.  Right now, my stored procedure starts out looking like this:

ALTER PROCEDURE [dbo].[NC_SHORTAGES]
(@Priority int,
 @PartNum varchar(80),
 @BldQty int)

So when I run the report, it prompts for those three fields.  But I need to be able to enter multiple part numbers, with a priority and build quantity for each.

In the Code section below is my entire stored procedure.  I think I will have to change this a little as well to process multiple input part numbers, right?

I'm so very stuck.  Please let me know what other information I can provide.  Thank you!
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
ALTER PROCEDURE [dbo].[NC_SHORTAGES] 
(@Priority int,
 @PartNum varchar(80),
 @BldQty int)
 
    AS 
    BEGIN
        
        If IsNull(object_id('tempdb..##partqty'),0) <> 0 DROP TABLE ##partqty
        CREATE table ##partqty (level integer, seq integer,
                               parpart char(30), parrev char(12), 
                               chpart char(30), chrev char(12), 
                               pdesc char(50), reqqty integer, uom char(4),
                               typecd char(1), path char(40),
                               whse char(7), ohqty integer, 
                               allocqty integer, nonnetqty integer, 
                               avqty integer, onordr integer,
                               ppath char(50))
                               
		SET NOCOUNT ON
 
; WITH BOM AS (SELECT     0 AS LEVEL, 000 AS seq, part.partnum AS parent, revisionnum AS P_revisionnum, part.partnum, 
                          revisionnum AS C_revisionnum, partdescription, CONVERT(decimal(18, 8), 0) AS qty, ium, typecode, 
                          CONVERT(varchar(800), (CONVERT(varchar(2), @Priority) + part.partnum)) AS path
               FROM         part INNER JOIN
                                 NC_PARTREV2 ON part.partnum = NC_PARTREV2.partnum
               WHERE     part.partnum = @PartNum
                                    UNION ALL
               SELECT     B. LEVEL + 1, CONVERT(int, M.mtlseq), M.partnum, R.revisionnum, M.mtlpartnum, CR.revisionnum, 
                          P.partdescription, CONVERT(decimal(18, 8), M.qtyper), P.IUM, P.typecode, 
                          CONVERT(varchar(800), b.path + ',' + CONVERT(varchar(10), M.mtlseq))
               FROM         BOM B INNER JOIN
                                  PARTMTL M ON M.partnum = B.partnum INNER JOIN
                                  NC_PARTREV2 R ON R.partnum = B.partnum AND M.revisionnum = R.revisionnum INNER JOIN
                                  PART P ON P.partnum = M.mtlpartnum INNER JOIN
                                  NC_PARTREV2 CR ON CR.partnum = P.partnum)
    
                         
   INSERT INTO ##partqty
     (level, seq, parpart, parrev, chpart, chrev, pdesc, reqqty, uom, typecd, path, whse, ohqty, 
             allocqty, nonnetqty, avqty, ppath)
     SELECT     LEVEL, seq, parent, P_revisionnum, bom.partnum, C_revisionnum, partdescription, 
                (@BldQty * qty) AS QtyNeeded, ium, typecode, path, warehousecode, onhandqty, allocqty, 
                nonnettableqty, (onhandqty + nonnettableqty - allocqty), path
     FROM       BOM INNER JOIN
                partwhse ON bom.partnum = partwhse.partnum
     ORDER BY path
   
select * from ##partqty order by ppath;
	END
	RETURN
[+][-]09/22/09 04:56 PM, ID: 25398816Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09/22/09 11:26 PM, ID: 25400445Assisted Solution

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]09/23/09 05:56 AM, ID: 25402517Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/23/09 07:48 AM, ID: 25403717Assisted Solution

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]09/24/09 07:32 AM, ID: 25413723Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zones: Crystal Reports Software, SQL Server 2005
Tags: input parameters, stored procedure
Sign Up Now!
Solution Provided By: MTaft
Participating Experts: 2
Solution Grade: A
 
[+][-]09/25/09 09:08 PM, ID: 25428773Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091021-EE-VQP-81 - Hierarchy / EE_QW_3_20080625