P.S. I do also use the variable outside a loop you can't see. I will post the entire procedure here. If the forum strips out white space (which I think it does), you can just paste the procedure into a SQL window and use the [great!] "Edit/"PLSQL Beautifier" feature to make it readable again. So here is the full procedure:
--
--
PROCEDURE uar_ipclink (p_test IN VARCHAR2 DEFAULT 'Y') AS
--
-- created to perform an IPC-Link user review:
-- A) First, send a "documentation" email to VP-Technology and VP-IS to document how the review was done:
-- 1) document the steps performed to conduct the review; this code is a procedure in a package in database
-- and will be included as an attachment with the first email (A.2.a)
-- 2) simple lists of IPC-Link usernames at the time of the review (A.2.a and A.2.b are in separate emails)
-- a) complete list of active IPC-Link usernames
-- b) (hopefully) empty list of ACTIVE IPC-Link usernames MINUS usernames being emailed
-- c) list of IPC-Link usernames being reviewed
-- B) sends emails to a reviewer for each region of IPC-Link usernames, with a list/subset of usernames to review
-- C) THIS IS A MANUAL STEP! The reviewer (e.g. Pat or Nane) will also need to document that the review was completed successfully
-- To accomplish this, he will repeatedly remind reviewers to return their responses. Once all of the
-- responses have been received, the reviewer will send an email to VP-Tech, VP-IS confirming review is complete.
--
--
v_subject VARCHAR2(200);
v_message CLOB;
v_source_code CLOB;
v_prov_count INTEGER;
v_line_count INTEGER;
v_prev_region casem.regions.region%TYPE;
v_err_info VARCHAR2(150) := NULL;
--
c_reviewer CONSTANT VARCHAR2(100) := 'Fred Jamkotchian ' ;
-- c_reviewer CONSTANT VARCHAR2(100) := 'Pat Holmes ' ; -- testing
c_developer CONSTANT VARCHAR2(100) := 'Pat Holmes ' ;
c_closing CONSTANT VARCHAR2(300) := 'Thank you for your time and patience,' ||
'Pat Holmes, VP Technology
' ||
'on behalf of
' ||
'Pat Holmes, VP Technology
' ||
'Fred Citron, VP Information Systems' ;
--
PROCEDURE start_ED_email (p_region IN VARCHAR2, p_to_email IN VARCHAR2) IS
BEGIN
--
v_subject := 'Please confirm these providers for ' || p_region || ' region';
--
-- build header for email:
--
-- logo:
-- v_message := '
';
-- no logo:
v_message := '';
--
v_message := v_message ||
'You are receiving this email because you are the Executive Director for the
' || p_region || ' region. (' || REPLACE(REPLACE(p_to_email,'') || ')'
|| '
It is imperative that you respond so that we can provide this documentation to our auditors. Please read below and then reply to the email.'
|| 'All of the providers below are ACTIVE IPC-Link users. The last three columns show how many encounters each provider has billed in the last 7 days, last 90 days and last 365 days.'
|| 'Our SOX auditors require that we ask you to confirm whether all of these providers should remain ACTIVE IPC-Link users. See the list below:
'
|| ' * If
all of the providers below
should remain active, just reply with "KEEP ALL".
'
|| ' * If
some of these providers can be removed, please indicate which ones to remove by putting the word "Remove" in the "Remove?" column for those that can be deactivated. Leave the first column blank if the provider should stay active.'
|| 'Note that for any providers that we remove, we will need the appropriate termination PAN or form if one doesn''t exist already. We will follow up with your staff if we need anything.'
|| 'Note also that our SOX auditors require that we do this twice-annually, once in June and once in December.'
;
END;
--
PROCEDURE send_ED_email (p_to_email IN VARCHAR2) IS
BEGIN
--
v_message := v_message || '[/TABLE]' || c_closing;
--
v_message := v_message || '';
--
IF p_to_email IS NOT NULL THEN
--
admin.email_pkg.set_email_server;
IF p_test = 'Y' THEN
admin.send_email_pkg.send(p_sender => c_reviewer,
p_recipients => c_developer,
p_bcc => c_developer,
p_subject => v_subject,
p_message => v_message,
p_mime_type => 'text/html');
ELSE
admin.send_email_pkg.send(p_sender => c_reviewer,
-- p_recipients => c_developer, -- s/b p_to_email, -- use this only for Testing
p_recipients => p_to_email,
p_bcc => c_developer,
p_subject => v_subject,
p_message => v_message,
p_mime_type => 'text/html');
END IF;
ELSE
dbms_output.put_line('>: missing to-email: ');
END IF;
END;
--
BEGIN
--
-- dbms_output.put_line (p_test);
--
--
/*
dbms_output.put_line('remember to turn on "SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;"');
dbms_output.put_line('remember to turn on "SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;"');
dbms_output.put_line('remember to turn on "SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;"');
dbms_output.put_line('remember to turn on "SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;"');
dbms_output.put_line('remember to turn on "SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;"');
*/
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
-- to guarantee read-consistency from beginning to end:
-- just in case the helpdesk adds or drops a user while this is running
-- this also requires a ROLLBACK or COMMIT at the end (I'll use a Rollback since this email does not change anything anyway):
--
--
--
--
--
DECLARE
c_header CONSTANT VARCHAR2(500) :=
'
#'
|| '[TH]Reg#'
|| '[TH]Region'
|| '[TH]Title'
|| '[TH]Last Name'
|| '[TH]First name'
|| '[TH]Username'
|| ' | | | | | | |
---|
' || TO_CHAR(v_prov_count) || ' | ' || TO_CHAR(v_line_count) || ' | ' || u_rec.region || ' | ' || u_rec.title || ' | ' || u_rec.last_name || ' | ' || u_rec.first_name || ' | ' || u_rec.username || ' |
'
|| '
'
|| '
[TH]';
BEGIN
--
--
-- A: send the documentation emails first
--
--
-- A.1: add source code as an attachment to the A.2.a email
-- A.2.a: show list of all ACTIVE IPC-Link usernames
--
--
--
v_subject := 'Documentation email for IPC-Link UAR: A.1, A.2.a: ALL Active IPC-Link usernames';
--
v_message := '';
--
--
BEGIN
v_message := v_message ||
'A.1: See attachment for the source code for entire package, but only uar_ipclink is called for the IPC-Link UAR:';
--
SELECT TRIM(dbms_metadata.get_ddl('PACKAGE', 'UAR_PKG', 'PHOLMES'))
INTO v_source_code
FROM dual;
-- v_message := v_message || v_source_code;
END;
--
--
v_message := v_message ||
'A.2.a: List of ALL IPC-Link usernames at the time the UAR process was executed:';
--
-- column heading:
v_message := v_message || c_header;
--
v_line_count := 0;
v_prov_count := 0;
FOR u_rec IN ( SELECT hp.region, NVL(TRIM(hppgcv.title),'(full-time)') title,
hp.last_name, hp.first_name, hp.username
FROM casem.hubs h, casem.health_prof_pg_current_view hppgcv,
casem.health_profs hp
WHERE hppgcv.health_prof_id = hp.health_prof_id
AND hp.hospitalist_flag = 'Y'
AND hppgcv.status = 'ACTIVE'
AND hp.username IS NOT NULL
AND hp.last_name != 'TEST'
AND h.hub = hp.hub
AND h.ipc_flag = 'Y'
ORDER BY 1, 2, 3, 4
) LOOP
v_line_count := v_line_count + 1;
v_prov_count := v_prov_count + 1;
IF v_prov_count = 1 THEN
v_prev_region := u_rec.region;
ELSIF v_prev_region != u_rec.region THEN
v_line_count := 1;
END IF;
-- dbms_output.put_line(u_rec.username);
--
v_message := v_message || '
';
v_message := v_message || '
';
v_message := v_message || '
';
v_message := v_message || '
';
v_message := v_message || '
';
v_message := v_message || '
';
v_message := v_message || '
';
v_message := v_message || '
';
v_message := v_message || '
';
--
v_prev_region := u_rec.region;
END LOOP;
--
v_message := v_message || '
';
-- dbms_output.put_line(' ');
--
-- now close and send email:
--
v_message := v_message || c_closing;
v_message := v_message || '';
--
admin.email_pkg.set_email_server;
admin.send_email_pkg.send_attach_clob(p_sender => c_reviewer,
p_recipients => c_developer,
p_bcc => c_developer,
p_subject => v_subject,
p_message => v_message,
p_attachment => v_source_code,
p_att_filename => 'UAR_source_code.txt',
p_mime_type => 'text/html');
--
--
--
-- A.2.b: documentation email: show that the ((All ACTIVE usernames) MINUS (Usernames being mailed to EDs)) is an empty list
-- A.2.c: documentation email: show list of all IPC-Link usernames that are being emailed to EDs
--
--
v_subject := 'Documentation email for IPC-Link UAR: A.2.b, A.2.c: Active users being emailed to EDs';
--
v_message := '';
--
v_message := v_message ||
'A.2.b: ((All ACTIVE usernames) MINUS (Usernames being mailed to EDs)) is an empty list:';
--
-- column heading:
v_message := v_message || c_header;
--
-- A.3.a:
v_line_count := 0;
v_prov_count := 0;
FOR u_rec IN ( ( SELECT hp.region, NVL(TRIM(hppgcv.title),'(full-time)') title,
hp.last_name, hp.first_name, hp.username
FROM casem.hubs h, casem.health_prof_pg_current_view hppgcv,
casem.health_profs hp
WHERE hppgcv.health_prof_id = hp.health_prof_id
AND hp.hospitalist_flag = 'Y'
AND hppgcv.status = 'ACTIVE'
AND hp.username IS NOT NULL
AND hp.last_name != 'TEST'
AND h.hub = hp.hub
AND h.ipc_flag = 'Y'
)
MINUS
( SELECT hp.region, NVL(TRIM(hppgcv.title),'(full-time)') title,
hp.last_name, hp.first_name, hp.username
FROM pholmes.employees_in_adp e, casem.gl_health_profs glhp,
casem.hubs h, casem.health_prof_pg_current_view hppgcv, casem.health_profs hp,
( SELECT eb.billing_health_prof_id,
SUM(DECODE(p.patient_id,NULL,0,DECODE(SIGN(TRUNC(SYSDATE)-eb.date_of_service- 7),1,0,1))) count_charges_7_days,
SUM(DECODE(p.patient_id,NULL,0,DECODE(SIGN(TRUNC(SYSDATE)-eb.date_of_service- 90),1,0,1))) count_charges_90_days,
SUM(DECODE(p.patient_id,NULL,0,DECODE(SIGN(TRUNC(SYSDATE)-eb.date_of_service-365),1,0,1))) count_charges_365_days
FROM casem.patients p, casem.patient_encounters pe, casem.encounter_billings eb
WHERE p.patient_id = pe.patient_id
AND pe.encounter_id = eb.encounter_id
AND p.last_name != 'TEST'
AND eb.date_of_service > SYSDATE - 365
AND eb.cpt_cd != 0
GROUP BY eb.billing_health_prof_id ) b,
( SELECT DISTINCT hp.region, rm.region_group,
DECODE(rm.region_group,'PETERSON, FRED','Fred Peterson ',
'PETERSON, FREDDY','Fred Peterson ',
INITCAP(iu.first_name || ' ' || iu.last_name) || ' ' to_email
FROM casem.gl_health_profs glhp, casem.ipcm_users iu, casem.region_mapping rm,
casem.hubs h, casem.health_prof_pg_current_view hppgcv, casem.health_profs hp
WHERE hppgcv.health_prof_id = hp.health_prof_id
AND glhp.health_prof_id(+) = hp.health_prof_id
AND h.hub = hp.hub
AND h.ipc_flag = 'Y'
AND rm.region = hp.region
AND iu.last_name(+) = UPPER(rm.region_group)
AND iu.title(+) = 'ED'
AND hp.last_name != 'TEST'
AND hp.hospitalist_flag = 'Y'
AND hp.username IS NOT NULL
AND hppgcv.status = 'ACTIVE'
AND h.ipc_flag = 'Y'
ORDER BY hp.region ) r
WHERE r.region(+) = hp.region
AND b.billing_health_prof_id(+) = hp.health_prof_id
AND e.emplid(+) = DECODE(casem.is_number(glhp.hp_clock),1,TO_NUMBER(glhp.hp_clock),NULL)
AND hppgcv.health_prof_id = hp.health_prof_id
AND glhp.health_prof_id(+) = hp.health_prof_id
AND h.hub = hp.hub
AND h.ipc_flag = 'Y'
AND hp.last_name != 'TEST'
AND hp.hospitalist_flag = 'Y'
AND hp.username IS NOT NULL
AND hppgcv.status = 'ACTIVE'
)
ORDER BY 1,2,3,4
) LOOP
v_line_count := v_line_count + 1;
v_prov_count := v_prov_count + 1;
IF v_prov_count = 1 THEN
v_prev_region := u_rec.region;
ELSIF v_prev_region != u_rec.region THEN
v_line_count := 1;
END IF;
v_message := v_message || '[TR]';
v_message := v_message || '[TD]' || TO_CHAR(v_prov_count) || '[/TD]';
v_message := v_message || '[TD]' || TO_CHAR(v_line_count) || '[/TD]';
v_message := v_message || '[TD]' || u_rec.region || '[/TD]';
v_message := v_message || '[TD]' || u_rec.title || '[/TD]';
v_message := v_message || '[TD]' || u_rec.last_name || '[/TD]';
v_message := v_message || '[TD]' || u_rec.first_name || '[/TD]';
v_message := v_message || '[TD]' || u_rec.username || '[/TD]';
v_message := v_message || '[/TR]';
--
v_prev_region := u_rec.region;
END LOOP;
--
v_message := v_message || '[/TABLE]';
--
v_message := v_message ||
'A.2.c: List of ALL IPC-Link usernames that are being emailed to EDs:';
--
-- column heading:
v_message := v_message || c_header;
--
v_line_count := 0;
v_prov_count := 0;
FOR u_rec IN ( SELECT hp.region, NVL(TRIM(hppgcv.title),'(full-time)') title,
hp.last_name, hp.first_name, hp.username
FROM pholmes.employees_in_adp e, casem.gl_health_profs glhp,
casem.hubs h, casem.health_prof_pg_current_view hppgcv, casem.health_profs hp,
( SELECT eb.billing_health_prof_id,
SUM(DECODE(p.patient_id,NULL,0,DECODE(SIGN(TRUNC(SYSDATE)-eb.date_of_service- 7),1,0,1))) count_charges_7_days,
SUM(DECODE(p.patient_id,NULL,0,DECODE(SIGN(TRUNC(SYSDATE)-eb.date_of_service- 90),1,0,1))) count_charges_90_days,
SUM(DECODE(p.patient_id,NULL,0,DECODE(SIGN(TRUNC(SYSDATE)-eb.date_of_service-365),1,0,1))) count_charges_365_days
FROM casem.patients p, casem.patient_encounters pe, casem.encounter_billings eb
WHERE p.patient_id = pe.patient_id
AND pe.encounter_id = eb.encounter_id
AND p.last_name != 'TEST'
AND eb.date_of_service > SYSDATE - 365
AND eb.cpt_cd != 0
GROUP BY eb.billing_health_prof_id ) b,
( SELECT DISTINCT hp.region, rm.region_group,
DECODE(rm.region_group,'PETERSON, FRED','Fred Peterson ',
'PETERSON, FREDDY','Fred Peterson ',
INITCAP(iu.first_name || ' ' || iu.last_name) || ' ' to_email
FROM casem.gl_health_profs glhp, casem.ipcm_users iu, casem.region_mapping rm,
casem.hubs h, casem.health_prof_pg_current_view hppgcv, casem.health_profs hp
WHERE hppgcv.health_prof_id = hp.health_prof_id
AND glhp.health_prof_id(+) = hp.health_prof_id
AND h.hub = hp.hub
AND h.ipc_flag = 'Y'
AND rm.region = hp.region
AND iu.last_name(+) = UPPER(rm.region_group)
AND iu.title(+) = 'ED'
AND hp.last_name != 'TEST'
AND hp.hospitalist_flag = 'Y'
AND hp.username IS NOT NULL
AND hppgcv.status = 'ACTIVE'
AND h.ipc_flag = 'Y'
ORDER BY hp.region ) r
WHERE r.region(+) = hp.region
AND b.billing_health_prof_id(+) = hp.health_prof_id
AND e.emplid(+) = DECODE(casem.is_number(glhp.hp_clock),1,TO_NUMBER(glhp.hp_clock),NULL)
AND hppgcv.health_prof_id = hp.health_prof_id
AND glhp.health_prof_id(+) = hp.health_prof_id
AND h.hub = hp.hub
AND h.ipc_flag = 'Y'
AND hp.last_name != 'TEST'
AND hp.hospitalist_flag = 'Y'
AND hp.username IS NOT NULL
AND hppgcv.status = 'ACTIVE'
ORDER BY 1,2,3,4
) LOOP
v_line_count := v_line_count + 1;
v_prov_count := v_prov_count + 1;
IF v_prov_count = 1 THEN
v_prev_region := u_rec.region;
ELSIF v_prev_region != u_rec.region THEN
v_line_count := 1;
END IF;
v_message := v_message || '[TR]';
v_message := v_message || '[TD]' || TO_CHAR(v_prov_count) || '[/TD]';
v_message := v_message || '[TD]' || TO_CHAR(v_line_count) || '[/TD]';
v_message := v_message || '[TD]' || u_rec.region || '[/TD]';
v_message := v_message || '[TD]' || u_rec.title || '[/TD]';
v_message := v_message || '[TD]' || u_rec.last_name || '[/TD]';
v_message := v_message || '[TD]' || u_rec.first_name || '[/TD]';
v_message := v_message || '[TD]' || u_rec.username || '[/TD]';
v_message := v_message || '[/TR]';
--
v_prev_region := u_rec.region;
END LOOP;
--
v_message := v_message || '[/TABLE]';
--
-- now close and send email:
--
v_message := v_message || c_closing;
v_message := v_message || '';
--
admin.email_pkg.set_email_server;
admin.send_email_pkg.send(p_sender => c_reviewer,
p_recipients => c_developer,
p_bcc => c_developer,
p_subject => v_subject,
p_message => v_message,
p_mime_type => 'text/html');
END;
--
--
--
--
--
--
-- B.1 now send providers to be approved by the EDs
--
DECLARE
--
-- send emails to ED for each region
--
v_prev_email VARCHAR2(50);
v_prev_title VARCHAR2(20);
c_prov_header CONSTANT VARCHAR2(600) :=
'
#'
|| '[TH]Remove?'
|| '[TH]Title'
|| '[TH]Last Name'
|| '[TH]First Name'
|| '[TH]Username'
|| '[TH]Start Date'
|| '[TH]# Encs
7 days'
|| '[TH]# Encs
90 days'
|| '[TH]# Encs
365 days'
|| ' |
---|
'
|| '
'
|| '
[TH]';
--
-- IPC-Link usernames to be reviewed
-- note the "p_region" parameter: we will send one email per region (e.g. if an ED is ED for five regions, that person will get five emails)
--
CURSOR c_prov IS
SELECT hp.region, NVL(TRIM(hppgcv.title),'(full-time)') title,
hp.last_name, hp.first_name, hp.username, hppgcv.actual_start_date,
NVL(b.count_charges_7_days,0) count_charges_7_days,
NVL(b.count_charges_90_days,0) count_charges_90_days,
NVL(b.count_charges_365_days,0) count_charges_365_days,
glhp.hp_clock, e.emplid, e.it_uid, e.emplstatus, hppgcv.status,
hppgcv.start_date pg_start_date, hppgcv.pg_id, hp.health_prof_id,
r.region_group, r.to_email
FROM pholmes.employees_in_adp e, casem.gl_health_profs glhp,
casem.hubs h, casem.health_prof_pg_current_view hppgcv, casem.health_profs hp,
( SELECT eb.billing_health_prof_id,
SUM(DECODE(p.patient_id,NULL,0,DECODE(SIGN(TRUNC(SYSDATE)-eb.date_of_service- 7),1,0,1))) count_charges_7_days,
SUM(DECODE(p.patient_id,NULL,0,DECODE(SIGN(TRUNC(SYSDATE)-eb.date_of_service- 90),1,0,1))) count_charges_90_days,
SUM(DECODE(p.patient_id,NULL,0,DECODE(SIGN(TRUNC(SYSDATE)-eb.date_of_service-365),1,0,1))) count_charges_365_days
FROM casem.patients p, casem.patient_encounters pe, casem.encounter_billings eb
WHERE p.patient_id = pe.patient_id
AND pe.encounter_id = eb.encounter_id
AND p.last_name != 'TEST'
AND eb.date_of_service > SYSDATE - 365
AND eb.cpt_cd != 0
GROUP BY eb.billing_health_prof_id ) b,
( SELECT DISTINCT hp.region, rm.region_group,
DECODE(rm.region_group,'PETERSON, FRED','Fred Peterson ',
'PETERSON, FREDDY','Fred Peterson ',
INITCAP(iu.first_name || ' ' || iu.last_name) || ' ' to_email
FROM casem.gl_health_profs glhp, casem.ipcm_users iu, casem.region_mapping rm,
casem.hubs h, casem.health_prof_pg_current_view hppgcv, casem.health_profs hp
WHERE hppgcv.health_prof_id = hp.health_prof_id
AND glhp.health_prof_id(+) = hp.health_prof_id
AND h.hub = hp.hub
AND h.ipc_flag = 'Y'
AND rm.region = hp.region
AND iu.last_name(+) = UPPER(rm.region_group)
AND iu.title(+) = 'ED'
AND hp.last_name != 'TEST'
AND hp.hospitalist_flag = 'Y'
AND hp.username IS NOT NULL
AND hppgcv.status = 'ACTIVE'
AND h.ipc_flag = 'Y'
ORDER BY hp.region ) r
WHERE r.region(+) = hp.region
AND b.billing_health_prof_id(+) = hp.health_prof_id
AND e.emplid(+) = DECODE(casem.is_number(glhp.hp_clock),1,TO_NUMBER(glhp.hp_clock),NULL)
AND hppgcv.health_prof_id = hp.health_prof_id
AND glhp.health_prof_id(+) = hp.health_prof_id
AND h.hub = hp.hub
AND h.ipc_flag = 'Y'
AND hp.last_name != 'TEST'
AND hp.hospitalist_flag = 'Y'
AND hp.username IS NOT NULL
AND hppgcv.status = 'ACTIVE'
-- AND hp.region IN ('ALA','AUS','CHI','DEN') -- test, test, test!
ORDER BY 1,2,3,4 ;
BEGIN
--
v_prov_count := 0;
FOR c_prov_rec IN c_prov LOOP
--
dbms_output.put_line(v_prev_email);
--
v_err_info := c_prov_rec.region || ',' || c_prov_rec.title || ',' || c_prov_rec.last_name;
v_prov_count := v_prov_count + 1;
--
IF v_prov_count = 1 THEN
--
-- this only happens once, on initial record in cursor
-- initialize variables
v_prev_region := c_prov_rec.region;
v_prev_email := c_prov_rec.to_email;
v_prev_title := c_prov_rec.title;
v_line_count := 1;
-- start new email
start_ED_email(c_prov_rec.region, c_prov_rec.to_email);
-- column headings
v_message := v_message || c_prov_header;
--
ELSIF c_prov_rec.region != v_prev_region THEN
--
-- end of region, so close-and-send email, then start new email
IF v_prev_email IS NOT NULL THEN
send_ED_email(v_prev_email);
END IF;
start_ED_email(c_prov_rec.region, c_prov_rec.to_email);
-- column headings
v_message := v_message || c_prov_header;
-- reset within-email variables to start new email (the line # counter, the first title)
v_line_count := 1;
v_prev_title := c_prov_rec.title;
--
ELSE
v_line_count := v_line_count + 1;
END IF;
--
IF c_prov_rec.title != v_prev_title THEN
v_message := v_message || '
';
v_message := v_message || c_prov_header || '
';
END IF;
-- now display data for current row:
BEGIN
/*
dbms_output.put(' --> ');
dbms_output.put_line(c_prov_rec.region
|| ',' || c_prov_rec.title
|| ',' || c_prov_rec.last_name
|| ',' || c_prov_rec.first_name
|| ',' || c_prov_rec.username
|| ',' || c_prov_rec.status
|| ',' || TO_CHAR(c_prov_rec.actual_start_date,'MM/DD/YYYY')
|| ',' || TO_CHAR(c_prov_rec.pg_start_date,'MM/DD/YYYY')
|| ',' || c_prov_rec.count_charges_7_days
|| ',' || c_prov_rec.count_charges_90_days
|| ',' || c_prov_rec.count_charges_365_days );
*/
--
v_message := v_message || '[TR]';
v_message := v_message || '[TD]' || TO_CHAR(v_line_count) || '[/TD]';
v_message := v_message || '[TD]' || ' ' || '[/TD]';
v_message := v_message || '[TD]' || c_prov_rec.title || '[/TD]';
v_message := v_message || '[TD]' || c_prov_rec.last_name || '[/TD]';
v_message := v_message || '[TD]' || c_prov_rec.first_name || '[/TD]';
v_message := v_message || '[TD]' || c_prov_rec.username || '[/TD]';
v_message := v_message || '[TD]' || TO_CHAR(c_prov_rec.actual_start_date,'MM/DD/YYYY') || '[/TD]';
v_message := v_message || '[TD]' || TO_CHAR(c_prov_rec.count_charges_7_days) || '[/TD]';
v_message := v_message || '[TD]' || TO_CHAR(c_prov_rec.count_charges_90_days) || '[/TD]';
v_message := v_message || '[TD]' || TO_CHAR(c_prov_rec.count_charges_365_days) || '[/TD]';
v_message := v_message || '[/TR]';
END;
v_prev_region := c_prov_rec.region;
v_prev_email := c_prov_rec.to_email;
v_prev_title := c_prov_rec.title;
-- next region
END LOOP c_prov_rec;
--
-- send email after last provider
send_ED_email(v_prev_email);
--
dbms_output.put_line('v_prov_count= ' || TO_CHAR(v_prov_count));
--
END;
--
--
--
--
--
--
--
-- even though no data changed, need to rollback if using "SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;"
ROLLBACK;
--
EXCEPTION WHEN OTHERS THEN
dbms_output.put_line('Region,Title,LastName: ' || v_err_info || ': ' || SQLERRM || ': ' || DBMS_UTILITY.FORMAT_ERROR_BACKTRACE);
admin.event_log_pkg.log_event(p_user_name => USER,
p_program_name => 'PHOLMES.UAR_PKG.UAR_IPCLINK',
p_event_desc => 'Region,Title,LastName: ' || v_err_info || ': ' || SQLERRM || ': ' || DBMS_UTILITY.FORMAT_ERROR_BACKTRACE);
END; -- uar_ipclink
--