Print Page | Close Window

Urgent: I need to pass a variable to a stored proc

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2022
Forum Name: Data Connectivity
Forum Discription: How to connect to data sources and export reports
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=1957
Printed Date: 09 Apr 2025 at 9:11am


Topic: Urgent: I need to pass a variable to a stored proc
Posted By: aruplabs
Subject: Urgent: I need to pass a variable to a stored proc
Date Posted: 31 Dec 2007 at 8:30am

I work for a health care provider and I have reports that pull PHI (Protected Health Information) about patients that needs to be logged according to federal HIPAA regulations. One of the pieces of information that needs to be logged is the username of the person who ran the report. Since these reports will be run from our Crystal Enterprise server I can get this from the CurrentCEUserName variable but I am looking for a way to pass this value to a stored procedure that will not only return the records for the report, but also log the disclosure in our PHI disclosure tracking table. I know you can pass a parameter to a stored procedure but I dont know how, or if it is even possible, to pass a run time variable. This is an urgent problem that I need to find a solution for. Any help would be appreciated.

 Thank you.



-------------
Martin Miller
IT Database Analyst
ARUP Laboratories



Replies:
Posted By: BrianBischof
Date Posted: 31 Dec 2007 at 4:12pm
Hilfy is the resident Crystal Enterprise expert on the forum and she has already done similar things. Search the forum for her posts and you'll find something similar that I remember being posted months back. Here is some generic info that might help.

Yes, you can pass a parameter to a stored procedure. Simply create the stored procedure with the necessary Input parameter and then create a new report using that stored procedure as the data source. CR will create a parameter in the report that will pass the data to it. The problem is that you need to populate the parameter with the user name prior to running the report. Otherwise, the user will be prompted to enter their user name prior to running the report (this might be ok, but most likely an irritant to the user). If you are using CR.NET, then you can do this programatically using the object model. Most likely, you are just using plain CR XI. Another option is to make the report a subreport of a blank main report. In the main report, use a formula to get the user name and then link that formula to the subreport's user name parameter. When the subreport runs, the parameter will have the correct user name in it and pass this to the SP.

-------------
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>



Print Page | Close Window