************************************************************ * PROCEDURE GetEmployeesQueuesInfo() ************************************************************ * Author............: Nadya Nosonovsky * Project...........: Visual Collections * Created...........: 06/16/2005 16:46:12 * Copyright.........: (c) Jzanus, 2005 *) Description.......: * Calling Samples...: * Parameter List....: * Major change list.: procedure GetEmployeesQueuesInfo lparameters tdDate, tcAlias local ltTime if empty(m.tcAlias) tcAlias = 'c_EmployeesQueuesInfo' endif if empty(m.tdDate) tdDate = date() endif ltTime = dtot(m.tdDate + 1)-1 if not used('Trans') use MMVisCollect!trans in 0 again alias trans endif if not used('Trans_Employees_Queues') use MMVisCollect!Trans_Employees_Queues in 0 ; again alias Trans_Employees_Queues endif if not used('Employee_Queue_Schedules') use MMVisCollect!Employee_Queue_Schedules in 0 ; again alias Employee_Queue_Schedules endif select cTrans_Employees_Queues_fk ; from Employee_Queue_Schedules EQS ; where EQS.tScheduled_time <= m.ltTime and EQS.iActive_Flag = 1 ; into cursor curFirst select TEQ.cTrans_fk, ; TEQ.cCommission_Owner_UsGrLink_fk as cUsGrLink_pk from ; Trans_Employees_Queues TEQ ; inner join curFirst ; on TEQ.cTrans_Employees_Queues_pk = curFirst.cTrans_Employees_Queues_fk ; where TEQ.iActive_Flag = 1 ; union all ; select TEQ.cTrans_fk, ; TEQ.cUsGrLink_fk as cUsGrLink_pk from ; Trans_Employees_Queues TEQ ; inner join curFirst ; on TEQ.cTrans_Employees_Queues_pk = curFirst.cTrans_Employees_Queues_fk ; where TEQ.iActive_Flag = 1 ; and TEQ.iTemporary_Assignment_Flag = 1 and ; TEQ.tStart_Date <= m.ltTime and ; TEQ.tExpire_Date >= m.tdDate into cursor step1 use in curFirst ** Possible problem - account assigned to the same investigator as commissioned and temp owner select count(trans.cTrans_pk) as iAccounts_Count, ; step1.cUsGrLink_pk, ; sum(trans.yCurrent_balance_amount) as yBalance ; from trans ; INNER join step1 ; on trans.cTrans_pk = step1.cTrans_fk ; where trans.cResolution_Codes_fk is null ; group by 2 into cursor (m.tcAlias) readwrite use in step1 select (m.tcAlias) index on cUsGrLink_pk tag cUsgrlink return endprocWe need to find a way to run this SP on the server, then it would be faster. So, I guess, I may need to try it as a separate dll to retrieve the data. Any ideas here?