You are on page 1of 7

--by Name (new)

select dSet.workflowid
,dSet.time
,dSet.FileName as InFile
,reverse(substr(outW.rText,1,instr(outW.rText,'/',1,1)-1)) as OutFile
,dSet.RecordSubType
,dSet.DetailText
from (Select w.workflowid
,w.createdate
,to_char(w.createdate,' hh:mi:ss am ') as time
,f4.FileName
,w.RecordSubType
,w.DetailText
--,outW.rText as tempOutFile
from workflowlog w
inner join
(select *
from (select *
from (select workflowid
,reverse(substr(FileName,1,instr(FileName,' ',1,1)
-1)) as FileName
from (select workflowid
,replace(reverse(substr(FileName,1,instr(FileNa
me,'.txt',1,1)+3)),'/',' ') as FileName
from (select workflowid
,CAST(DetailText AS VARCHAR2(1000)
) as FileName
from workflowlog
where createdate > sysdate -1
) f0
--change the file name below (keep the %
s)
where FileName like '%CR_014111_100439_CAMP_10
1220_142001.txt%'
and FileName not like '%AS_0%'
and FileName not like '%duplicate%'
) f1
) f2
group by workflowid
,FileName
) f3
) f4
on w.workflowid = f4.workflowid
--where DetailText not like '%FtpUploadProcess%'
) dSet
left outer join
(select workflowid
, reverse(cast(DetailText as varchar(200))) as rText
from workflowlog
where DetailText like'%.csv%'
and createdate > sysdate -1
) outW
on outW.workflowid = dSet.workflowid
order by dSet.WorkFlowID desc
,dSet.RecordSubType

,CAST(instr(dSet.DetailText, 'There ',1,1) AS VARCHAR2(50)) desc


,cast(dSet.DetailText as varchar(2000))
;
--All processes
select * from tbljobqueue order by createdate desc;
--by WorkFlowID
select * from workflowlog where workflowid = '12444';
--RUN THE FOLLOWING SQL QUERY IF YOU GET DUPLICATE FILE ERROR
delete from tblworkflowheaderproperty where element = 'AS_OF_DATE';
commit;
--SQL ENDS
--by Name (old)
select dSet.workflowid
,dSet.time
,dSet.FileName as InFile
,reverse(substr(dSet.tempOutFile,1,instr(dSet.tempOutFile,'/',1,1)-1)) as O
utFile
,dSet.RecordSubType
,dSet.DetailText
from (Select w.workflowid
,w.createdate
,to_char(w.createdate,' hh:mi:ss am ') as time
,f2.FileName
,w.RecordSubType
,w.DetailText
,(select reverse(cast(DetailText as varchar(200))) as rText
from workflowlog outW
where rownum =1
and outW.workflowid = w.workflowid
and DetailText like'%.csv%'
) as tempOutFile
from workflowlog w
inner join
(select *
from (select workflowid
,CAST(substr(DetailText, 30, instr(DetailText, ' for t
emplate ',1,1)-30) AS VARCHAR2(50)) as FileName
from workflowlog
where DetailText like '%Create Notification for file %'
) f1
where f1.FileName = 'S_014111_100439_CAMP_403499_101118_142003.txt
'
) f2
on w.workflowid = f2.workflowid
) dSet
order by dSet.WorkFlowID desc
,dSet.RecordSubType
,CAST(instr(dSet.DetailText, 'There ',1,1) AS VARCHAR2(50)) desc
,cast(dSet.DetailText as varchar(2000))
;
--Email Notification

select s.senddate,s.templateid,r.emailaddress,r.personid,r.firstname,r.lastname,
a.attribute1,a.attribute2,a.attribute3,a.attribute4,a.attribute5,a.attribute6,a.
attribute7,a.attribute8,a.attribute9,a.attribute10,a.attribute11,a.attribute12,a
.attribute13, s.LYRISMESSAGESETTINGSID
from LyrisMessageSettings s
join LyrisMessageRecipient r on s.LYRISMESSAGESETTINGSID = r.LYRISMESSAGESETTING
SID
join LyrisMessageRecipientAttribute a on a.LyrisMessageRecipientid = r.LyrisMess
ageRecipientid
where templateid like '%Outbound%'
and to_char( s.senddate,'mm/dd/yyyy') = to_char(sysdate,'mm/dd/yyyy')
order by s.senddate desc;
--retrieve Lyris extract data
select s.senddate,s.templateid,s.emailrequesttype,s.replyto,s.lookuprecipientinf
o,s.sendername,s.senderemailaddress,persontype,
r.emailaddress,r.personid,r.firstname,r.lastname,r.clientid,r.address1,r.address
2,r.city,r.state,r.zip,r.country,
a.attribute1,a.attribute2,a.attribute3,a.attribute4,a.attribute5,a.attribute6,a.
attribute7,a.attribute8,a.attribute9,a.attribute10,a.attribute11,a.attribute12,a
.attribute13, s.LYRISMESSAGESETTINGSID
from LyrisMessageSettings s
join LyrisMessageRecipient r on s.LYRISMESSAGESETTINGSID = r.LYRISMESSAGESETTING
SID
join LyrisMessageRecipientAttribute a on a.LyrisMessageRecipientid = r.LyrisMess
ageRecipientid
--where templateid like '%Feedback%'
--where templateid like '%Outbound%'
--and to_char( s.senddate,'mm/dd/yyyy') = to_char(sysdate,'mm/dd/yyyy')
order by s.senddate desc;
select * from workflowlog where workflowid = '8092' and detailtext like '%303165
943%';
select * from tblworkflowheaderproperty;
select * from customer where username = '555550021';
update tblworkflowheaderproperty set propertyvalue = '09/06/2010' where element
like '%FEEDBACK%';
commit;
select * from tblworkflowheaderproperty where element like '%FEEDBACK%' order by
workflowid desc;
Select tj.*,to_char(P.PROPERTYVALUE) as AS_OF_DATE from tblJobQueue tj
join tblworkflowheaderproperty p on p.workflowid = tj.workflowid and p.element
= 'AS_OF_DATE'
join tblworkflowheaderproperty p2 on p2.workflowid = tj.workflowid and p2.eleme
nt = 'FILETYPE' and to_char(p2.propertyvalue)='SEED'
order by tj.workflowid desc;
--login info qry
select px.plan_xsid,ap.description,lx.location_xsid,c.username,ea.attribute_valu
e as employee_id,cl.login_id,cl.login_password,ae.status as osda_status,c.firstn
ame,c.lastname,c.date_of_birth,a.email,LC.ORIG_HIRE_DATE,lc.adj_hire_date,ae.eli
gible as plan_entry_date,
PYC.CONTRIBUTION_YTD,ms.sourcename,LC.ANNUAL_SALARY,LC.YTD_HRS,LC.YEARS_SERVICE,
AE.ENABLED as plan_entry_status

from
accountenrollment ae
join accountlocations al on al.id = ae.accountlocation_id
left outer join participant_ytd_contri pyc on pyc.accountsourceid = ae.accounten
rollmentid and PYC.FIN_YEAR = 2010
left outer join accountsource asr on asr.accountsourceid = pyc.accountsourceid
left outer join mastersources ms on ms.mastersourcesid = asr.mastersourcesid
join location l on l.id = al.location_id
join employer e on e.id = l.employer_id
join customer c on c.customerid = ae.customerid
join employer_customer ec on ec.customerid = c.customerid and ec.employer_id = e
.id
left outer join customer_login cl on cl.parent_id = ec.employer_customer_id
join location_customer lc on lc.location_id = l.id and lc.customer_pk = c.pk
join address a on a.parentid=to_char(lc.location_customer_id) and a.parenttable
= 'LOCATION_CUSTOMER'
join extended_attribute ea on EA.PARENT_ID = to_char(lc.location_customer_id) an
d ea.attribute_type = 'CLIENT_EMPLOYEE_ID'
join locationxsmapping lx on lx.location_id = l.id
join accountsprovided ap on ap.accountsprovidedid = ae.accountsprovidedid
join planxsmapping px on px.accountsprovidedid = ap.accountsprovidedid
where
ae.status in( 'ELIGIBLE','ACTIVE', 'TERMED' )
--and cl.login_password = '1111111p'
--and ap.description = 'CALIFORNIA INSTITUTE OF TECHNOLOGY 457(B) DEFERRED COMP'
--and cl.login_id = 'CAL013055'
/*
and
(cl.login_id = 'CAL950276'
or cl.login_id = 'MV950266'
)
*/
and c.username = '654321123'
--c.username = '555555034'
--order by c.username,l.id,ae.accountenrollmentid
order by username desc
;
--!login info
-- Check address modified date
select a.* from LOCATION_CUSTOMER lc join ADDRESS a on (a.PARENTID = to_char(lc.
LOCATION_CUSTOMER_ID) and a.PARENTTABLE = 'LOCATION_CUSTOMER')
join CUSTOMER c on lc.CUSTOMER_PK = c.pk
where c.USERNAME = '303010476';
-- Set address modified date
update ADDRESS set modified = DATE '2010-08-30' where PARENTID =
(select to_char(lc.LOCATION_CUSTOMER_ID) from location_customer lc
join CUSTOMER c on lc.CUSTOMER_PK = c.pk
where c.USERNAME = '303010476');
commit;
-- feedback uses to determine whether a guy makes it into the file
select ae.*,c.PK as customerPK, lc.STATUS as lCustEmpStatus, lc.STATUS_EFFECTIVE
_DATE as lCustStatusEffDate from accountenrollment ae

join accountlocations al on al.ID = ae.accountlocation_ID


join customer c on c.customerid = ae.customerid
join location_customer lc on lc.customer_pk = c.pk and lc.location_id =
al.location_id
join address a on a.parentid = to_char(lc.location_customer_id)
where lc.location_id = 1 and al.ID in (select id from
accountlocations where location_id = 1)
-- active and address modified in [lastCutoffDate, cutoffDate)
and ( ( ae.status = 'ACTIVE' and a.modified >= SYSDATE and a.modified < S
YSDATE )
-- active and compliance applied in (lastFeedbackDate, feedbackDate]
or ( ae.status = 'ACTIVE' and ae.compliance_applied_date > DATE '2010-06-3
0' and ae.compliance_applied_date <= DATE '2010-08-23' )
-- active and hardship applied in (lastFeedbackDate, feedbackDate]
or ( ae.status = 'ACTIVE' and ae.hardship_applied_date > DATE '2010-06-30'
and ae.hardship_applied_date <= DATE '2010-08-23' )
-- active and hardship applied in (lastFeedbackDateButOne, lastFeedbackDate]
-- (and hence not in (lastFeedbackDate, feedbackDate) -- picks up hardship suspe
nsion end
or ( ae.status = 'ACTIVE' and ae.hardship_applied_date > DATE '2010-05-30'
and
ae.hardship_applied_date <= DATE '2010-06-30' )
-- pending and effective start date in [lastCutoffDate, cutoffDate]
or ( ae.status = 'PENDING' and ae.effective_start_date >= DATE '2010-08-01
' and ae.effective_start_date < SYSDATE ) ) ;
-- feedback dates being used
select wfh.workflowid, whp.element, whp.propertyvalue from workflowactivity wfh
join vwworkflowheaderproperty whp on wfh.workflowID = whp.workflowID
where wfh.processID = 24 and wfh.processStatusID = 241
and whp.element in ('FEEDBACK_DATE', 'CUTOFFDATE')
order by wfh.createdate desc ;
select c.username, c.lastname, c.customerID, c.date_of_birth, pv.valuetext, ap.d
escription, ap.accountsprovidedid, ae.accountenrollmentid, px.plan_xsid, ms.sour
cename,pyc.contribution_ytd, PD.DEFERRALAMOUNT, pd.deferralpercent,pd.compliance
_deferralamount,
ph.acc_per_pay_comp, ph.bonus, ph.per_pay_comp, ae.compliance_applied, ae.compli
ance_applied_date, ae.compliance_applied_402g1, ae.compliance_applied_415, ae.co
mpliance_applied_401a17, ae.deduct_method, ap.client_id, ae.hardship_status, al.
location_id
from customer c
join accountenrollment ae on ae.customerID = c.customerID
join participant_ytd_contri pyc on pyc.accountsourceID = ae.accountenrollmentID
join participantdeferrals pd on pd.accountenrollmentID = ae.accountenrollmentID
and pyc.accountsourceid = pd.accountenrollmentid and pd.accountsourceid = pyc.ac
countsourceid
join accountlocations al on al.id = ae.accountlocation_ID
join accountsprovided ap on ap.accountsprovidedID = al.accountsprovidedID and ae
.accountsprovidedid = ap.accountsprovidedid
join propertyvalue pv on pv.valueID = ap.type_of_account and pv.p_key = 'PLAN_TY
PE'
join accountsource asrc on asrc.accountsourceID = pd.ACCOUNTSOURCEID and pyc.acc
ountsourceid=asrc.accountsourceid and asrc.accountsourceid = pd.accountsourceid
and asrc.accountsprovidedid = ae.accountsprovidedid
join mastersources ms on ms.mastersourcesID = asrc.mastersourcesID

join planxsmapping px on px.accountsprovidedid = ap.accountsprovidedid


join location_customer lc on lc.customer_pk = c.pk
join payroll_hist ph on ph.location_customer_id = lc.location_customer_id
join extended_attribute ea on ea.parent_id = lc.location_customer_id
where
ae.status = 'ACTIVE'
--and c.username = '201221028'
and ph.fin_year='2010'
--and c.username = '200950554'
--and c.customerID in ( select customerID from accountenrollment where accounten
rollmentid = '1095385002660')
and ea.parent_table = 'LOCATION_CUSTOMER'
and ea.attribute_value = '303110476'
--and al.location_id = '210120'
order by c.username, ap.accountsprovidedID, al.location_id ;
--to reset feedback process (to run in the same day)
Select * from workflowactivity where processid = 24 and processstatusid = 241 or
der by createdate desc; --run 1st
--take workflowid from 1st entry (which should be the same day as today) and cop
y that into the following qrys.
--change date to a few days before today's date
update tblworkflowheaderproperty set propertyvalue = '10/25/2010' where workflow
id = 14834 and element = 'CUTOFFDATE';
update tblworkflowheaderproperty set propertyvalue = '10/25/2010' where workflow
id = 14834 and element = 'FEEDBACK_DATE';
update accountenrollment set feedback_included_date = null;
commit;
--FEEDBACK by Pankaj
--First find the last feedback workflowid, this you can find by running the foll
wing sql
select * from tbljobqueue where processid = 24 and processstatusid = 241 order b
y workflowid desc;
-- Use the above found workflowid in subsequent sqls.
-- run this sql and make sure the client, employer, location ids are all correct
select * from tblworkflowheaderproperty where workflowid = 12312;
--first find the workflowid for the last run feedback file with the same schedul
e,
--the schedule_id you'll be getting from above select statement
select workflowid from tblworkflowheaderproperty where element = 'SCHEDULE_ID'
and to_char(propertyvalue) = 'a302276b9dfa4c5eab8d8ca517d68fa6' order by created
ate desc;
-- Use the above found workflowid in subsequent sqls.
select * from tblworkflowheaderproperty where workflowid = 12092;
-- change the cutoffdate ( you're changing these values for last feedback proces
s run, so these will be become your last cutoffdate and last feedback date respe
ctively)
-- to be yesterday's date if you want to pick up changes since yesterday,
-- or today if you just want to pick up changes from today, and remember the cut
offdate you choose on the schedule should never be equal to the one here,
-- even processing date should not be equal to the feedback date you put here
update tblworkflowheaderproperty set propertyvalue = '12/20/2010' where element
= 'CUTOFFDATE' and workflowid = 12312;
update tblworkflowheaderproperty set propertyvalue = '12/22/2010' where element
= 'FEEDBACK_DATE' and workflowid = 12312;

-- This is to make sure if you've run the feedback the same day, you will reset
the ae flag to pick records again, here the date should be processing date of cu
rrent feedback
update accountenrollment ae set ae.feedback_included_date = null where ae.feedba
ck_included_date = to_date('12/21/2010', 'mm/dd/yyyy');
--Once your feedback has completed processing, IMMEDIATELY run this query and pa
ste the
--results here:
select workflowid, element, propertyvalue from tblworkflowheaderproperty
where workflowid = (select max(workflowid) from tbljobqueue
where processid = 24)
and element in
('CUTOFFDATE', 'LAST_CUTOFFDATE', 'FEEDBACK_DATE',
'LAST_FEEDBACK_DATE', 'PAYROLLDATE')
order by element asc;
--from Aleicia
--George asked me to distribute this since there are many test cases with eDocum
ents testing.
--As is, it selects all customer and eDocuments information for eDocuments ALREA
DY IN EXISTENCE.
--Edit accordingly for the different purposes you may use it for.
Select cu.*, cd.* --all customer data shown, all document data shown
From Customer Cu
Join Employer_Customer Ec On Ec.Customerid = Cu.Customerid
Join Customer_Document Cd On Cd.Employer_Customer_Id = Ec.Employer_Customer_Id
where
cd.method = 'EDELIVERY' --ONLY select eDocuments. Change to 'POST' or comment ou
t this line as necessary
and edelivery_id is not null --ONLY select customers for which a document alread
y exists
--and cu.username = '0000000000' --Uncomment this line to view a particular cust
omer and fill in the proper username/ssn
;

You might also like