Link to home
Start Free TrialLog in
Avatar of paigea
paigea

asked on

How do I create a CRYSTAL Report utilizing a command with parmlist

I need to create a Crystal Report -Error Report and use a command to select my data.  I need to use the command instead of select expert as I need this performed on the server because there are timeout issues.  I need to select errors within a parameter start date and end date and also only companys that are selected via the parm.  Below I have attached the sql that I am trying to get to work in the command.  When I enter parameters in the command screen, they do not stay?? Also I am not quite sure how to code using the parameters within the command.
Command code
SELECT  "TABLE"."IVR_CALL_HEADER"."START_DATE", 
        "TABLE"."IVR_META_ERROR"."ERROR_ID"
      ,COUNT("TABLE"."IVR_META_ERROR"."ERROR_ID") AS ERROR
 
  FROM "TABLE"."IVR_ERROR_EVENT"
      ,"TABLE"."IVR_META_ERROR" 
      ,"TABLE"."IVR_EVENT"      
      ,"TABLE"."IVR_STATE"      
      ,"TABLE"."IVR_CALL_HEADER"
 
 WHERE "TABLE"."IVR_ERROR_EVENT"."META_ERROR_ID" = "TABLE"."IVR_META_ERROR"."META_ERROR_ID"
   AND "TABLE"."IVR_ERROR_EVENT"."EVENT_ID" = "TABLE"."IVR_EVENT"."EVENT_ID"
   AND "TABLE"."IVR_STATE"."STATE_ID" = "TABLE"."IVR_EVENT"."STATE_ID"
   AND "TABLE"."IVR_STATE"."CALL_ID" = "TABLE"."IVR_CALL_HEADER"."CALL_ID"
AND "TABLE"."IVR_CALL_HEADER"."START_DATE" IN (?STARTDATE) TO( ?ENDDATE)
(I am not sure how to accomplish the following)
AND iif({?Company}='All',TRUE,{?Company}={IVR_CALL_HEADER.APPLICATION_NAME})
    
GROUP BY   "TABLE"."IVR_CALL_HEADER"."START_DATE",
              "TABLE"."IVR_META_ERROR"."ERROR_ID"
Open in New Window Select All 
Tags:

Open in new window

Avatar of Mike McCracken
Mike McCracken

You can create a COMMAND as the datasource when you build the report.

Use the PARAMETER option in the command popup to add the parameters to allow the users to specify the filtering

mlmcc
I am not sure I follow why you need to create a command object. While the timeout is a problem maybe the sql is not the issue. Can you provide more background?

I only question this because when you set up your parameters then you can use your if statement in this fashion: if {?Company}='All' then true else company = {?Company}.  Most of the time if you set the filters up so they are passed to the database you will get an improvement in performance.
Assuming you're using a relatively modern database (this syntax won't work with Oracle 8i, for example), try the following.

SELECT
  E.START_DATE, 
  B.ERROR_ID,
  COUNT(B.ERROR_ID) AS "ERROR"
FROM
  "TABLE"."IVR_ERROR_EVENT" A
  INNER JOIN "TABLE"."IVR_META_ERROR" B ON A.META_ERROR_ID = B.META_ERROR_ID
  "TABLE"."IVR_EVENT" C ON A.EVENT_ID = C.EVENT_ID
  "TABLE"."IVR_STATE" D ON A.STATE_ID = D.STATE_ID
  "TABLE"."IVR_CALL_HEADER" E ON D.CALL_ID = E.CALL_ID
WHERE
  E.START_DATE IN (?STARTDATE) TO (?ENDDATE)
  AND ('{?Company}' = 'All' OR E.APPLICATION_NAME = '{?Company}')
GROUP BY
  E.START_DATE,
  B.ERROR_ID

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Kurt Reinhardt
Kurt Reinhardt
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial