开发者

passing multivalue parameter to stored procedure

I am having troubles passing multiple parameter to the crystal report stored procedure. I have a stored procedure which works fine as long as ?StockNumber parameter is single value. When I try to change it to multivalue 2 things happen: whether it shows a message: "This stored procedures cannot accept multiple values". or if try to directly enable parameter in procedure to accept multiple values it just closes an application without any errors. As far as I understand this is a limitation of stored procedures, not crystal reports. Anyways I need to fix this. I just do not know how to manipulate parameters in crystal reports environment. please discuss. Thanks!

   SELECT 
      "table1"."StockNum"
      , "table1"."StockOnhand"
      , "table1"."StockNumber"
      , "table1"."StockLocation"
      ,"table2"."StockDesc"
      ,"table2"."StockDesc2"
      , "TotalSoldItems"."SoldItems"
    FROM   
      "AAG1"."DB2"."table1" "table1"
    LEFT JOIN
    (
    SELECT 
      SUM ("StockNumAA"."StockNumQuantity") "SoldItems"
      , "StockNumAA"."from"
    FROM    
      "AAG1"."DB2"."StockNumAA" "StockNumAA"
    WHERE  "StockNumAA"."code"='BB' 
      AND "StockNumAA"."StockNumber" = '{?3PartNumber}'
      AND ("StockNumAA"."date">={?1StartDate}
      AN开发者_如何学CD "StockNumAA"."date"<={?2EndDate})
    GROUP BY 
       "StockNumAA"."from"
     ) "TotalSoldItems"
    ON "table1"."StockLocation" = "TotalSoldItems"."from"
    LEFT JOIN 
    "AAG1"."DB2"."table2" "table2"
    ON "table1"."StockNumber" = "table2"."Stocknumber"
    WHERE "table1"."StockNumber" = '{?Stocknumber}'


I am no crystal reports expert but generally when trying to pass a multi value to a stored procedure in SQL the accepted method is to pass it as a comma delimited string like such

 item1, item 2, item 3

Then you just write a function that can split them by the comma and return a set.

Edit: Again, I know nothing about crystal reports but I did a little research and found the excerpt from another forum. It discusses how to use a multi indentifier as a comma delimited string:

If your multi-value parameter is of type string, you can put this in the formula definition of the flattened parameter

{flattened_parameter}: 
Join({?YourMultiValueParameter},",") 
e.g. {?YourMultiValueParameter}[1] = US 
{?YourMultiValueParameter}[2] = Canada 
{?YourMultiValueParameter}[3] = UK 
=> {flattened_parameter} = US, Canada, UK 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜