Improving Performance of Crystal Reports using Stored Procedures
        Posted  
        
            by mjh41
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by mjh41
        
        
        
        Published on 2010-06-07T20:16:35Z
        Indexed on 
            2010/06/07
            20:22 UTC
        
        
        Read the original article
        Hit count: 547
        
Recently I updated a Crystal Report that was doing all of its work on the client-side (Selects, formulas, etc) and changed all of the logic to be done on the server-side through Stored Procedures using an Oracle 11g database. Now the report is only being used to display the output of the stored procedures and nothing else. Everything I have read on this subject says that utilizing stored procedures should greatly reduce the running time of the report, but it still takes roughly the same amount of time to retrieve the data from the server. Is there something wrong with the stored procedure I have written, or is the issue in the Crystal Report itself? Here is the stored procedure code along with the package that defines the necessary REF CURSOR.
CREATE OR REPLACE
PROCEDURE         SP90_INVENTORYDATA_ALL 
(
  invdata_cur IN OUT sftnecm.inv_data_all_pkg.inv_data_all_type,
  dCurrentEndDate IN vw_METADATA.CASEENTRCVDDATE%type,
  dCurrentStartDate IN vw_METADATA.CASEENTRCVDDATE%type
)
AS
BEGIN
  OPEN invdata_cur FOR
     SELECT 
      vw_METADATA.CREATIONTIME, 
      vw_METADATA.RESRESOLUTIONDATE, 
      vw_METADATA.CASEENTRCVDDATE, 
      vw_METADATA.CASESTATUS, 
      vw_METADATA.CASENUMBER,
      (CASE WHEN vw_METADATA.CASEENTRCVDDATE < dCurrentStartDate AND (
        (vw_METADATA.CASESTATUS is null OR vw_METADATA.CASESTATUS != 'Closed') OR
        TO_DATE(vw_METADATA.RESRESOLUTIONDATE, 'MM/DD/YYYY') >= dCurrentStartDate) then 1 else 0 end) InventoryBegin,
      (CASE WHEN (to_date(vw_METADATA.RESRESOLUTIONDATE, 'MM/DD/YYYY') BETWEEN dCurrentStartDate AND dCurrentEndDate) 
        AND vw_METADATA.RESRESOLUTIONDATE is not null AND vw_METADATA.CASESTATUS is not null then 1 else 0 end) CaseClosed,
      (CASE WHEN vw_METADATA.CASEENTRCVDDATE BETWEEN dCurrentStartDate AND dCurrentEndDate then 1 else 0 end) CaseCreated   
 FROM   vw_METADATA 
 WHERE  vw_METADATA.CASEENTRCVDDATE <= dCurrentEndDate
 ORDER BY vw_METADATA.CREATIONTIME, vw_METADATA.CASESTATUS;
END SP90_INVENTORYDATA_ALL;
And the package:
CREATE OR REPLACE PACKAGE inv_data_all_pkg
AS TYPE inv_data_all_type IS REF CURSOR
RETURN inv_data_all_temp%ROWTYPE;
END inv_data_all_pkg;
        © Stack Overflow or respective owner