Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Help with multiple value parameter Post Reply Post New Topic
Author Message
LegoAddict
Newbie
Newbie


Joined: 12 Jul 2013
Online Status: Offline
Posts: 2
Quote LegoAddict Replybullet Topic: Help with multiple value parameter
     Posted: 15 Jul 2013 at 12:50pm
Hi there, I'm learning to use Crystal and I'm also not great in SQL.

When creating a subreport that connects to a stored procedure I'm not able to expand it to select values during the report wizard or in the subreport.

I'm passing two paramaters, para1 a unique id and para2 a multiple value paramater. Basically I have a group that groups people based on statuses, there are about 13 different statuses. I want the stored procedure to do something based on 3 of those statuses and something else for the rest.

It's my understanding that to do this I have to use the join formula to pass this info to the stored procedure. I have done that, the formula is join({?Instant Status},","). It's linked to para2 in the subreport.

My stored procedure code is below. I'm not sure where I'm going wrong here. Any help would be appreciated and I apologize if I'm missing any info you need, please let me know!

Thanks!

CREATE PROCEDURE test @Para1 uniqueidentifier, @Para2 varchar(Max) as
    BEGIN

SELECT * INTO #MyTempTable  from Split(@Para2,',')

 IF EXISTS (SELECT  ITEM  FROM   #MyTempTable   WHERE  ITEM IN ('09 Candidate','08 TCP Interviewed', '06 Prospect'))

        select tCompany.CompanyName, tExperience.OfficialTitle, tExperience.StartDate, tExperience.Enddate from tPeople
    LEFT JOIN tExperience ON tPeople.GUID = tExperience.PeopleGUID
    LEFT JOIN tCompany ON tExperience.CompanyGUID = tCompany.GUID
    WHERE tPeople.GUID = @Para1

    EXCEPT

    select tCompany.CompanyName, tExperience.OfficialTitle, tExperience.StartDate, tExperience.Enddate from tPeople
    LEFT JOIN tExperience ON tPeople.CurrentExperienceGUID = tExperience.GUID
    LEFT JOIN tCompany ON tExperience.CompanyGUID = tCompany.GUID
    WHERE tPeople.GUID = @Para1

      ELSE
       
Return null

drop table #MyTempTable

END
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 18 Jul 2013 at 8:25am
I've run into this issue before.  You should be able to keep your stored proc as-is.  It's the format of the parameter that is causing an issue because Crystal stores multi-select parameters in arrays, not strings.  Since your stored proc is in a subreport, here's what you can do:
 
1.  Create a formula in the main report that will concatenate the values in the array.  It would look something like this:
 
StringVar multiParam := "";
for  i := 1 to Ubound({?MyParameter}) do
(
  if i = UBound({?MyParameter}) then
    multiParam := multiParam + {?MyParameter} 
  else
    multiParam := multiParam + {?MyParameter} + ",";
);
multiParam
 
You would then link from this formula to the parameter from the stored proc in the Subreport Links for your subreport - uncheck "Select data in in subreport based on data in field:" on the bottom right and select the appropriate parameter from the drop-down list on the bottom left.
 
-Dell


Edited by hilfy - 18 Jul 2013 at 8:26am
IP IP Logged
LegoAddict
Newbie
Newbie


Joined: 12 Jul 2013
Online Status: Offline
Posts: 2
Quote LegoAddict Replybullet Posted: 24 Jul 2013 at 8:11am
Originally posted by hilfy

I've run into this issue before.  You should be able to keep your stored proc as-is.  It's the format of the parameter that is causing an issue because Crystal stores multi-select parameters in arrays, not strings.  Since your stored proc is in a subreport, here's what you can do:
 
1.  Create a formula in the main report that will concatenate the values in the array.  It would look something like this:
 
StringVar multiParam := "";
for  i := 1 to Ubound({?MyParameter}) do
(
  if i = UBound({?MyParameter}) then
    multiParam := multiParam + {?MyParameter} 
  else
    multiParam := multiParam + {?MyParameter} + ",";
);
multiParam
 
You would then link from this formula to the parameter from the stored proc in the Subreport Links for your subreport - uncheck "Select data in in subreport based on data in field:" on the bottom right and select the appropriate parameter from the drop-down list on the bottom left.
 
-Dell


Thanks for the reply!

I've created a formula but I get the error "A variable name is expected here".

Does your code need any modification or should it work off the bat?
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 24 Jul 2013 at 8:15am
I missed something in the formula.  Try this:
 
StringVar multiParam := "";
for i := 1 to Ubound({?MyParameter}) do
(
if i = UBound({?MyParameter}) then
multiParam := multiParam + {?MyParameter}
else
multiParam := multiParam + {?MyParameter} + ",";
);
multiParam
 
-Dell
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum