title: Improving Performance of Crystal Reports using Stored Procedures
body: <p>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 <strong>REF CURSOR</strong>.</p>
  
  <pre><code>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 &lt; dCurrentStartDate AND (
          (vw_METADATA.CASESTATUS is null OR vw_METADATA.CASESTATUS != 'Closed') OR
          TO_DATE(vw_METADATA.RESRESOLUTIONDATE, 'MM/DD/YYYY') &gt;= 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 &lt;= dCurrentEndDate
   ORDER BY vw_METADATA.CREATIONTIME, vw_METADATA.CASESTATUS;
  END SP90_INVENTORYDATA_ALL;
  </code></pre>
  
  <p>And the package:</p>
  
  <pre><code>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;
  </code></pre>