Question

I need to pass a list of key values to a stored procedure in SQL-Server, and that stored procedure then returns back the values needed for a Crystal Report.

Rather than sending a comma separated list and then parsing that, it was suggested that I use a Table Type. So, I've defined that table type as simply made of integers:

CREATE TYPE [dbo].[SiteIdentifiers] AS TABLE 
(
    [SiteId]     BigInt, 
    PRIMARY KEY ([SiteId])
)

However, now I need to modify my Crystal Report to take that as an input parameter. (The stored procedure starts with...

CREATE  PROCEDURE [dbo].[sp_SiteReport]
    @SiteIds    [dbo].[SiteIdentifiers] ReadOnly
AS

The Reports will mostly be called with ColdFusion or C#.net, so I don't think there will be an issue in adding IDs to the table type. But I don't know how to define that parameter in Crystal. The list of Types in the Create New Parameter wizard is rahter scant.

Was it helpful?

Solution 3

As far as I can tell, this is not possible. Crystal does not take data types that it doesn't recognize from other applications, such as SQL Server.

OTHER TIPS

I don't think you're using the Parameter concept in Crystal the right way. To my knowledge, it's best used for manually entering data (and you're trying to pass a multi-dimensional array, not the best use of it). I recommend:

  1. Your first idea of feeding in the table as a comma-delimited string.
    OR
  2. Saving your procedure's output to a temporary table in the SQL-Server and importing that.

Normally, a Crystal report that runs off a procedure is created by pointing the report at the procedure - any required parameters for the procedure are automatically generated in the report. If you have done this in the Crystal Reports designer without the report generating the table input parameter, then I don't think you can do it this way.

As another alternative to using a comma-separated list, have you considered:

  • creating a table to hold session IDs and input values,
  • populating the table just prior to running the report with a session ID and the input values required,
  • passing the session ID to the report as a parameter,
  • passing the session ID from the report to the procedure as a parameter,
  • coding the procedure to select the input values from the new table based on the session ID, and removing the entries for the session ID after running the report?
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top