Print Page | Close Window

Stored Proc only executes if parameter changed

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=19928
Printed Date: 05 May 2024 at 9:18am


Topic: Stored Proc only executes if parameter changed
Posted By: statey603
Subject: Stored Proc only executes if parameter changed
Date Posted: 21 Aug 2013 at 9:46am
I have a Stored Procedure that takes a single input string parameter (and a ref cursor output parameter) in my report. The input parameter is fixed 'rpt1' so I don't have a parameter variable or need to prompt for it - just a quoted string in the SQL calling the stored procedure. The stored procedure executes when I first set up the report, however, subsequent executions and refresh, and the stored proc does not execute.
 
The stored procedure updates the last run date of the specified report [rpt1] in this case. this report needs to run with no user intervention so a parameter prompt will not work - unless there is a way to force it to always use a default value.
 
any ideas, suggestions?
 
 
Command object:
 
DECLARE
  MyRptCur SYS_REFCURSOR;
BEGIN
  TMP_UPDT_LAST_RUN_PROC('rpt1', MyRptCur);
END;
 
CR2011, v14.
DB: Oracle
 


-------------
-bill



Replies:
Posted By: hilfy
Date Posted: 21 Aug 2013 at 10:11am
What is in the cursor that is returned?  Is is used anywhere on the report?  If it isn't, that might be your problem - Crystal won't run a command which doesn't have any fields referenced in the report.
 
-Dell


-------------
Proviti, Data & Analytics Practice
http://www.protiviti.com/US-en/data-management-advanced-analytics - www.protiviti.com/US-en/data-management-advanced-analytics


Posted By: statey603
Date Posted: 22 Aug 2013 at 2:30am
Hi Dell,
Funny you should ask. I forgot to mention this, but I have not been able to figure out how to display the return data. As mentioned above, the Stored Procedure has 2 parameters (string IN, refcursor OUT). When I set up the Crystal Report and put the call to the Stored Procedure in a Command object, I declare a refcursor, but am not sure how to include it on my report. 
 
I have also tried setting up a report with the Stored Procedure directly set up as my data source (no command object). This approach allows me to specify refcursor data fields on the report, but at runtime I am prompted to set the string input variable. I have to be able to have this report run with no user intervention. The input parameter will always be the same value. I tried setting a default for the parameter but am still prompted.
NOTE: This report does execute the stored procedure every time (because the input parameter is being set each time?), but this will not work for our needs of a stand-alone report.
 
I appreciate suggestions, etc.
 
 


-------------
-bill


Posted By: hilfy
Date Posted: 22 Aug 2013 at 3:07am
How are you running the report "with no user intervention"?
 
-Dell


-------------
Proviti, Data & Analytics Practice
http://www.protiviti.com/US-en/data-management-advanced-analytics - www.protiviti.com/US-en/data-management-advanced-analytics


Posted By: statey603
Date Posted: 22 Aug 2013 at 4:08am
The plan is for the report to be scheduled via Crystal Server.
 
We are replacing InfoReports with Crystal Reports. We have reports that are scheduled to run daily and some weekly. After a report runs, a post-run rpt runs that updates Last Run Date/Time specific to the scheduled report. The next time the report runs, it includes data added to the db since the last run time for that rpt. So I am trying to create these post-run rpts that will call a stored procedure and pass the rpt name so the last run table can be updated. The only thing the users see is a report printout when they come in in the morning. If there are problems executing the report, the post-run rpt will not update the last run so the next time it runs it still includes all data newer than the last time it ran.
 
If I try to hard-code the report name parameter and call the stored proc inside a command object, it does not execute so I am trying to figure out a way to make crystal think the parameter variable has been set.
 
 
 
 


-------------
-bill


Posted By: hilfy
Date Posted: 22 Aug 2013 at 4:21am
You can set the parameter as part of the schedule in Crystal.  So I would just connect to the stored procedure directly instead of using a command and let the scheduler handle the parameter for you.
 
-Dell


-------------
Proviti, Data & Analytics Practice
http://www.protiviti.com/US-en/data-management-advanced-analytics - www.protiviti.com/US-en/data-management-advanced-analytics


Posted By: statey603
Date Posted: 22 Aug 2013 at 4:45am
Oh.....that would work nice. I currently do not have access to the scheduler/server. Hopefully I get it soon as I am tasked with figuring out how to implement the functionality that we currently have with InfoRpts using Crystal. Do you know if there are any good places to find examples, tutporials, etc about the scheduler. I checked the SAP site and got lost.
 
Thanks,
Bill
 


-------------
-bill


Posted By: hilfy
Date Posted: 22 Aug 2013 at 5:49am
Crystal Server and BusinessObjects both run on the same code-base so the scheduling flow is the same for either application.  The user guides contain this information.  To get to the correct version of the user guide do the following:
 
For Crystal 2008, go to http://help.sap.com/boe31sp3#section7 - http://help.sap.com/boe31sp3#section7  and download the InfoView User Guide
 
For Crystal 2011, go to http://help.sap.com/bobip40#section8 - http://help.sap.com/bobip40#section8  and download the BI Launchpad User Guide for the correct service pack for your system.
 
-Dell


-------------
Proviti, Data & Analytics Practice
http://www.protiviti.com/US-en/data-management-advanced-analytics - www.protiviti.com/US-en/data-management-advanced-analytics


Posted By: statey603
Date Posted: 22 Aug 2013 at 6:42am
thank you very much. I was not able to find those when I looked earlier - the SAP site is a bit busy and everthing has similar names [business this, enterprise that, etc] . I appreciate your help !!!
- Bill


-------------
-bill


Posted By: statey603
Date Posted: 22 Aug 2013 at 9:47am
Update......
I found another way to accomplish what I need to do using a shared variable and subreport.
 

Created a new report with main report's data source as a table LAST_RUN_TBL.

Added a Formula: SetRptNme with a Shared Variable: RptNme

[Shared StringVar RptNme := "SERV_AUTH_V";] <--- report name text would need to be set based on rpt or possibly passed to rpt via scheduler.

Next, I added a subreport in the report footer section which references the Stored Procedure via Database Expert. the Stored Proc takes a string input [InReportName]

Then I selected Change Subreport Links (right-click on subrpt)

specified @SetRptNme from the main rpt and specified the subreport parameter field ?INREPORTNAME.

Now, when I run/refresh the report, there is no parameter prompting and the Last Run row gets updated.

 - Bill

 



-------------
-bill



Print Page | Close Window