cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2062
Views
3
Helpful
5
Replies

CUIC Custom Reporting Question

Kristopher Tan
Level 1
Level 1

We’re trying to create a report that tally’s up all of the calls handled for a specific Group # (customvariable3) and displays it per contact center area. I’ve included the xml Report Template Definition from our 8.6 environment. The result looks similar to:

In CUIC 10.5, we need the report to have a date filter on it like this:

The problem is, the results we get don’t tally up because of the inclusion of the date field in the results (which is expected).

select sdt, business_unit, grp as group, count(grp) as calls_handled

from (

select startdatetime as sdt, 'Business Unit A' as business_unit, TRIM (LEADING '0' from UPPER(TRIM(customvariable3)))as grp

from contactcalldetail

where TRIM(LEADING '0' from TRIM(customvariable3))in ('1001','1002','1003','1004','1005')

and contacttype = 1

and contactdisposition = 2

and applicationname in ('900_CustSvc_1', '900_CustSvc_2','900_CustSvc_3')

UNION ALL

select startdatetime as sdt, 'Business Unit B' as business_unit, TRIM (LEADING '0' from UPPER(TRIM(customvariable3))) as grp

from contactcalldetail

where TRIM(LEADING '0' from TRIM(customvariable3)) in ('2000','2001','2002','2003','2004')

and contacttype = 1

and contactdisposition = 2

and applicationname in ('900_CustSvc_1', '900_CustSvc_2','900_CustSvc_3')

UNION ALL

select startdatetime as sdt, 'Business Unit C' as business_unit, TRIM (LEADING '0' from UPPER(TRIM(customvariable3))) as grp

from contactcalldetail

where TRIM(LEADING '0' from TRIM(customvariable3)) not in ('3001','3002','3003','3004','3005')

and contacttype = 1

and contactdisposition = 2

and applicationname in ('900_CustSvc_1', '900_CustSvc_2','900_CustSvc_3')

UNION ALL

select startdatetime as sdt, 'Business Unit D' as business_unit, TRIM (LEADING '0' from UPPER(TRIM(customvariable3))) as grp

from contactcalldetail

where ( TRIM(LEADING '0' from TRIM(customvariable3))= ''

or customvariable4 is NULL)

and contacttype = 1

and contactdisposition = 2

and applicationname in ('900_CustSvc_1', '900_CustSvc_2','900_CustSvc_3')

)

group by business_unit, grp, sdt

I've been able to get the report to do the following using the grouping option, but again it doesn't tally up the calls handled...

So the question is what is it that I'm missing? I think I don't quite understand how the grouping option works but I'm not sure if that's the whole issue.  Any help would be very much appreciated.

Kris

1 Accepted Solution

Accepted Solutions

Kris,

A couple things...

  1. For your filter field, you need to set the "Data Clause" to whatever is expected by SQL or Informix in a WHERE statement.
  2. Your query probably won't work well with the filter field until you change your query. In your original query you're selecting from the union of 4 SELECT statements. I propose that you make a single SELECT statement. Each of your SELECTs is basically the same with the exception of the hard-coded "business_unit".

Here's an example to start you off with the CASE statement (modify as you see fit of course):

select 

business_unit = CASE

WHEN TRIM(LEADING '0' from TRIM(customvariable3))in ('1001','1002','1003','1004','1005') THEN 'Business Unit A'

WHEN TRIM(LEADING '0' from TRIM(customvariable3))in ('2001','2002','2003','2004','2005') THEN 'Business Unit B'

WHEN TRIM(LEADING '0' from TRIM(customvariable3))in ('3001','3002','3003','3004','3005') THEN 'Business Unit C'

ELSE 'Business Unit D' END,

TRIM (LEADING '0' from UPPER(TRIM(customvariable3)))as grp

from contactcalldetail

where contacttype = 1

and contactdisposition = 2

and applicationname in ('900_CustSvc_1', '900_CustSvc_2','900_CustSvc_3')

As you can see the query will be much simpler - no need for 4 subqueries.

- Jameson

-Jameson

View solution in original post

5 Replies 5

Kris,

The trick is to not include your datetime in the query, but instead create a "Filter Field" on the Fields tab of the report definition. In your case it looks like you'd need to rewrite the query some for it to work though. It should be possible to redo the whole query a bit simpler with a CASE statement for your business unit field instead of all the UNION statements.

-Jameson

-Jameson

Hi Jameson,

I don't quite follow in regards to rewriting the query and substituting a CASE statement. I removed the start date time (sdt) from the outer query and tried out the Filter Field. It seems it gives me a "Dataset status is failed Database Error" as follows:

Error information:
com.cisco.ccbu.cuic.businesslogic.datasource.CuicDbException: DbException: CuicDataSourceServiceManagerImpl.getDataSet() { Nested SQLException; SQLState: 42000 Vendor code: -201 Message: A syntax error has occurred. } at com.cisco.ccbu.cuic.businesslogic.datasource.CuicDataSourceServiceManagerImpl.getDataSetBuilder(CuicDataSourceServiceManagerImpl.java:952) at com.cisco.ccbu.cuic.businesslogic.engine.CuicReportEngineWorker.executeQueryUsingDatasetBuilder(CuicReportEngineWorker.java:80) at com.cisco.ccbu.cuic.businesslogic.engine.CuicReportEngineWorker.runReport(CuicReportEngineWorker.java:37) at com.cisco.ccbu.cuic.businesslogic.enginebase.Worker.run(Worker.java:329) at com.cisco.ccbu.infra.threads.InstrumentedRunnable.run(InstrumentedRunnable.java:92) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:619) at com.cisco.ccbu.infra.threads.ThreadPoolThread.run(ThreadPoolThread.java:164) Caused by: java.sql.SQLException: A syntax error has occurred. at com.informix.util.IfxErrMsg.getSQLException(IfxErrMsg.java:408) at com.informix.jdbc.IfxSqli.a(IfxSqli.java:3461) at com.informix.jdbc.IfxSqli.E(IfxSqli.java:3774) at com.informix.jdbc.IfxSqli.dispatchMsg(IfxSqli.java:2580) at com.informix.jdbc.IfxSqli.receiveMessage(IfxSqli.java:2496) at com.informix.jdbc.IfxSqli.executePrepare(IfxSqli.java:1360) at com.informix.jdbc.IfxPreparedStatement.e(IfxPreparedStatement.java:320) at com.informix.jdbc.IfxPreparedStatement.a(IfxPreparedStatement.java:300) at com.informix.jdbc.IfxPreparedStatement.(IfxPreparedStatement.java:170) at com.informix.jdbc.IfxSqliConnect.h(IfxSqliConnect.java:6537) at com.informix.jdbc.IfxSqliConnect.prepareStatement(IfxSqliConnect.java:2453) at sun.reflect.GeneratedMethodAccessor562.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.mchange.v2.c3p0.stmt.GooGooStatementCache$1StmtAcquireTask.run(GooGooStatementCache.java:525) at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547) Caused by: java.sql.SQLException at com.informix.util.IfxErrMsg.getSQLException(IfxErrMsg.java:408) at com.informix.jdbc.IfxSqli.E(IfxSqli.java:3779) ... 13 more

No clue what that means... I'm assuming it doesn't like substituting the Filter Field date into the query for some reason?

Kris,

A couple things...

  1. For your filter field, you need to set the "Data Clause" to whatever is expected by SQL or Informix in a WHERE statement.
  2. Your query probably won't work well with the filter field until you change your query. In your original query you're selecting from the union of 4 SELECT statements. I propose that you make a single SELECT statement. Each of your SELECTs is basically the same with the exception of the hard-coded "business_unit".

Here's an example to start you off with the CASE statement (modify as you see fit of course):

select 

business_unit = CASE

WHEN TRIM(LEADING '0' from TRIM(customvariable3))in ('1001','1002','1003','1004','1005') THEN 'Business Unit A'

WHEN TRIM(LEADING '0' from TRIM(customvariable3))in ('2001','2002','2003','2004','2005') THEN 'Business Unit B'

WHEN TRIM(LEADING '0' from TRIM(customvariable3))in ('3001','3002','3003','3004','3005') THEN 'Business Unit C'

ELSE 'Business Unit D' END,

TRIM (LEADING '0' from UPPER(TRIM(customvariable3)))as grp

from contactcalldetail

where contacttype = 1

and contactdisposition = 2

and applicationname in ('900_CustSvc_1', '900_CustSvc_2','900_CustSvc_3')

As you can see the query will be much simpler - no need for 4 subqueries.

- Jameson

-Jameson

Hi Jameson,

I got things close to working using your suggestion. Oddly enough, I get the following:

Looks like business_unit is returning a Boolean for some reason. It looked like it forced it to that when I ran the Create Fields button on the Data Source page. I can't seem to find a place to redefine it as a string instead and the Delete doesn't work to remove it either. Am I doing something wrong? I ran the same query through MS SQL Server Management Studio against the Informix DB and it came out with the proper string values Business Unit A, B, C in that first column... So does the reporting tool expect something different in the query?

Kristopher Tan
Level 1
Level 1

Hi Jameson,

After a moderate amount of hair pulling, I figured out that CUIC doesn't interpret the SQL query the same as MSSQL Server Management Studio. CUIC appears to be quite finicky and the errors it gives are not very helpful. The end result was this query:

select  (CASE

WHEN TRIM(LEADING '0' from TRIM(customvariable3))in ('1001','1002','1003','1004','1005') THEN 'Business Unit A'

WHEN TRIM(LEADING '0' from TRIM(customvariable3))in ('2001','2002','2003','2004','2005') THEN 'Business Unit B'

WHEN TRIM(LEADING '0' from TRIM(customvariable3))in ('3001','3002','3003','3004','3005') THEN 'Business Unit C'

ELSE 'Business Unit D' END) as 'business_unit',

TRIM (LEADING '0' from UPPER(TRIM(customvariable3))) as grp

count(customvariable3)

from contactcalldetail

where contacttype = 1

and contactdisposition = 2

and applicationname in ('900_CustSvc_1', '900_CustSvc_2','900_CustSvc_3')

group by customvariable3, customvariabl4

CUIC was seeing the 'business_case' = CASE portion as a Boolean while the MSSQL Server Management Studio's analyzer was returning the case strings.

Thanks again for your help!

Kris

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: