You are on page 1of 3

-----Script to Share the Standard Templates with User Groups-----

declare
ab number;
lvc NUMBER;
Begin
for i in (Select id from RPT_TEMPLT where quality_checked=1 and ORIG_TEMPLT_ID=0)
loop
for j in (
select id from user_group where name in (
'Administrators',
'Aggregate',
'Business Administrator',
'CSRM',
'Clinical',
'Global PV',
'MSR',
'Other Business Users',
'Quality Check',
'Reporting Services'
))
loop

SELECT
COUNT(1)
INTO
lvc
FROM RPT_TEMPLATE_USER_GROUP where report_template_id=i.id and
user_group_id=j.id;
if lvc<>1 then
execute immediate 'insert into RPT_TEMPLATE_USER_GROUP values('||i.id||','||
j.id||')';
end if;
end loop;
end loop;
end;
/
commit:
-----Script to Share the Standard Queries with User Groups-----

declare
ab number;
lvc NUMBER;
Begin
for i in (Select id from SUPER_QUERY where quality_checked=1 and ORIG_QUERY_ID=0)
loop
for j in (
select id from user_group where name in (
'Administrators',
'Aggregate',
'Business Administrator',
'CSRM',
'Clinical',
'Global PV',
'MSR',
'Other Business Users',
'Quality Check',
'Reporting Services'
))
loop
SELECT
COUNT(1)
INTO
lvc
FROM SUPER_QUERY_USER_GROUP where Query_id=i.id and user_group_id=j.id;
if lvc<>1 then
execute immediate 'insert into SUPER_QUERY_USER_GROUP values('||i.id||','||
j.id||')';
end if;
end loop;
end loop;
end;
/
commit;
-----Script to Share the Standard Reports with User Groups-----

declare
ab number;
lvc_cnt int;
lvc NUMBER;
GrpID NUMBER;
Begin
for i in (select id from delivery where report_id in (select id from rconfig where
quality_checked=1))
loop
for j in (
select id from user_group where name in (
'Administrators',
'Aggregate',
'Business Administrators',
'CSRM',
'Clinical',
'Global PV',
'MSR',
'Other Business Users',
'Quality Check',
'Reporting Services'
))
loop

SELECT
COUNT(1)
INTO
lvc
FROM DELIVERIES_SHARED_WITH_GRPS where DELIVERY_ID=i.id and
SHARED_WITH_GROUP_ID=j.id;
if lvc<>1 then
SELECT
nvl(max(SHARED_WITH_GROUP_IDX)+1,0)
INTO
grpID
FROM DELIVERIES_SHARED_WITH_GRPS where DELIVERY_ID=i.id and
SHARED_WITH_GROUP_ID is not NULL;

update DELIVERIES_SHARED_WITH_GRPS
set SHARED_WITH_GROUP_ID = j.id
where delivery_id=i.id and SHARED_WITH_GROUP_IDX=grpID;
select count(1)
into lvc_cnt
from DELIVERIES_SHARED_WITH_GRPS
where delivery_id =i.id
and SHARED_WITH_GROUP_ID= j.id
and SHARED_WITH_GROUP_IDX=grpID;

if lvc_cnt=0
then
insert into DELIVERIES_SHARED_WITH_GRPS(DELIVERY_ID, SHARED_WITH_GROUP_ID,
SHARED_WITH_GROUP_IDX)
values(i.id,j.id, grpID);
end if;

end if;
end loop;
end loop;
end;
/
commit;

You might also like