Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Pass multiple comma delimited values to subreport procedure

Posted on 2010-11-30
11
Medium Priority
?
481 Views
Last Modified: 2012-06-21
I have a sub-report with a procedure that has an id (string) parameter.
It can take multiple ids which are comma delimited ie ‘123,346,789’
If I run the sub report as its own report with the id = ‘123,346,789’ it returns the three values I need

If I pass one id (123) to the sub report from the main report it works fine.

However if I try to return more than one  value (‘123,346’) to the sub report, it blows up with the error
“Function stp_ReturnID has too many arguments specified”

How do I get it the subreport to recognize the multiple comma delimited values?
0
Comment
Question by:fundsf
[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
  • 6
  • 4
11 Comments
 
LVL 59

Accepted Solution

by:
HainKurt earned 1000 total points
ID: 34242125
"procedure that has an id (string) parameter"

can you please post the code for this... we need to modify the query...
0
 

Author Comment

by:fundsf
ID: 34242155
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go

Alter procedure [dbo].[stp_ReturnID]
            @FundIds                  varchar(8000),
            @FromDate                  datetime,
            @ToDate                        datetime,
            @IsAnnualized            bit = 0
as
begin

      create table #key_unstrung (
            key_id            int
            )

      exec stp_ParseIdList  @FundIds


      select      key_id as FundId,
                  f.FundName,
                  dbo.udf_ReturnDateRange( f.FundId, @FromDate, @ToDate, @IsAnnualized ) as [Return]
      from      #key_unstrung k with (nolock)
            join Funds f with (nolock) on f.FundId = k.key_id
      order by f.FundName

end
0
 
LVL 101

Assisted Solution

by:mlmcc
mlmcc earned 1000 total points
ID: 34242162
How are you passing the values to the subreport?

mlmcc
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
LVL 59

Expert Comment

by:HainKurt
ID: 34242303
is FundID in table also string?
0
 
LVL 59

Expert Comment

by:HainKurt
ID: 34242325
also post the code for stp_ParseIdList  
0
 
LVL 59

Expert Comment

by:HainKurt
ID: 34242346
you may use

select      key_id as FundId,
                  f.FundName,
                  dbo.udf_ReturnDateRange( f.FundId, @FromDate, @ToDate, @IsAnnualized ) as [Return]
      from      Funds f
      where ',' + @FundIds + ',' like '%,'+f.FundId+',%' like
      order by f.FundName

and remove following code

create table #key_unstrung (
            key_id            int
            )

      exec stp_ParseIdList  @FundIds

0
 
LVL 59

Expert Comment

by:HainKurt
ID: 34242352
oops, try this and remove previous code in your sp
select f.FundId,
       f.FundName,
       dbo.udf_ReturnDateRange( f.FundId, @FromDate, @ToDate, @IsAnnualized ) as [Return]
  from Funds f 
 where ',' + @FundIds + ',' like '%,'+f.FundId+',%' like 
 order by f.FundName

Open in new window

0
 

Author Comment

by:fundsf
ID: 34242414
I need to pass a formula/array to the stp.
Right now I have a a place holder '123,456,789'

If I pass the '123,456,789' straight to the stp parameter it works ,but not the formula place holder.

What it really needs to do is look at a pre-defined formula
if {?Index} = 'ABC' then 123
else
if {?Index} = 'DEF' then 345
else
if {?Index} = 'GHI' then 789.
Then build an comma delimited array based on that and pass it to the stp
fyi, The fundid is a number
0
 

Author Comment

by:fundsf
ID: 34242583
I had to get rid of the second like to modify the proc.

Now I get this error
Conversion failed when converting the varchar value '%,' to data type int
select f.FundId,
       f.FundName,
       dbo.udf_ReturnDateRange( f.FundId, @FromDate, @ToDate, @IsAnnualized ) as [Return]
  from Funds f 
 where ',' + @FundIds + ',' like '%,'+f.FundId+',%'
 order by f.FundName

Open in new window

0
 
LVL 59

Expert Comment

by:HainKurt
ID: 34243064
where ',' + @FundIds + ',' like '%,'+f.FundId+',%'

-->

where ',' + @FundIds + ',' like '%,' + cast(f.FundId as varchar) + ',%'
0
 

Author Closing Comment

by:fundsf
ID: 34253068
We ended up writing a different stp so I didn't have to pass the multiple ids
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

722 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