You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

477 lines
12 KiB

37060^Tabellen-Abgleich^--Freemarker Template\
<sqlvars>\
\
<sqlvar name="profile" type="hash">\
\
select name,\
uniquename,\
table_1,\
table_1_caption,\
table_2,\
table_2_caption,\
is_active,\
systeminfo_id,\
table_1_filter,\
table_2_filter\
\
FROM qa_tablecomp_profile \
where tid=<<Profil>> \
\
</sqlvar>\
<sqlvar name="pruefungen" type="hashsequence">\
\
select name,\
whereclause,\
is_active,\
priority,\
aggregationfield,\
aggregationfunction\
FROM qa_tablecomp_aggregation \
where qa_tablecomp_profile_id=<<Profil>> \
</sqlvar>\
<sqlvar name="fields" type="hashsequence">\
\
select name,\
priority,\
sortnr,\
caption\
FROM qa_tablecomp_field \
where qa_tablecomp_profile_id=<<Profil>>\
order by sortnr\
</sqlvar> \
-- Darf nur 1 Spalte sein!\
<sqlvar name="groupbycol" type="hash">\
SELECT fieldname,\
fieldcaption\
FROM qa_tablecomp_groupby \
where qa_tablecomp_profile_id=<<Profil>>\
</sqlvar> \
\
<sqlvar name="idcols" type="hashsequence">\
SELECT \
fieldname,\
fieldcaption\
FROM qa_tablecomp_idcol \
where qa_tablecomp_profile_id=<<Profil>>\
\
</sqlvar> \
\
</sqlvars>\
\
\
\
<#assign prio_filter="" />\
/* <#assign prio_filter=<<Priorität beim Feldabgleich>> /> */\
\
\
<#assign aggregation="<<Aggregation des Vergleichs>>" />\
\
create temp table tmp_abgleich\
(zeitraum integer,\
prio char(1),\
ord smallint,\
pruefung varchar(255),\
comparison varchar(255),\
fieldname varchar(255),\
fieldcaption varchar(255),\
result_table_1 varchar(255),\
result_table_2 varchar(255),\
result_code smallint,\
result_code_str varchar(255),\
hidden_summe text -- Link zu Detailbericht falls Differenz gefunden\
);\
\
create temp table tmp_abgleich_summen\
(zeitraum integer,\
ord smallint,\
pruefung varchar(255),\
comparison varchar(255),\
fieldname varchar(255),\
fieldcaption varchar(255),\
result_table_1 varchar(255),\
result_table_2 varchar(255),\
result_code smallint\
);\
\
create temp table tmp_abgleich_ds\
(zeitraum integer,\
ord smallint,\
pruefung varchar(255),\
comparison varchar(255),\
<#foreach idcol in idcols>\
${idcol.fieldname} varchar(255),\
</#foreach>\
result_table_1 varchar(255),\
result_table_2 varchar(255),\
result_code smallint,\
result_code_str varchar(255)\
);\
\
<#assign ord=0 />\
\
select * into temp tmp_table_1\
from ${profile.table_1} \
where 1=1\
<#if profile.table_1_filter !=""> and ${profile.table_1_filter} </#if>\
<#if "<<Zeitraum>>"!="">\
and ${groupbycol.fieldname}=<<Zeitraum>>\
</#if>\
;\
select * into temp tmp_table_2\
from ${profile.table_2} \
where 1=1\
<#if profile.table_2_filter !=""> and ${profile.table_2_filter} </#if>\
<#if "<<Zeitraum>>"!="">\
and ${groupbycol.fieldname}=<<Zeitraum>>\
</#if>\
;\
\
<#if aggregation=="1">\
--summen:\
<#foreach pruefung in pruefungen>\
<#if pruefung.priority!="P" && (pruefung.priority==prio_filter || prio_filter=="")>\
\
<#assign ord=ord+1 />\
\
\
insert into tmp_abgleich_summen\
(zeitraum,\
ord,\
pruefung,\
comparison,\
result_table_1,\
result_table_2\
)\
select ${groupbycol.fieldname},\
${ord},\
'${pruefung.name}',\
'${pruefung.aggregationfunction}',\
${pruefung.aggregationfunction}(${pruefung.aggregationfield})::integer,\
0\
from tmp_table_1\
where 1=1\
<#if pruefung.whereclause !=""> and ${pruefung.whereclause} </#if>\
group by ${groupbycol.fieldname}\
;\
\
insert into tmp_abgleich_summen\
(zeitraum,\
ord,\
pruefung,\
comparison,\
result_table_1,\
result_table_2\
)\
select ${groupbycol.fieldname},\
${ord},\
'${pruefung.name}',\
'${pruefung.aggregationfunction}',\
0,\
${pruefung.aggregationfunction}(${pruefung.aggregationfield})::integer\
from tmp_table_2\
where 1=1\
<#if pruefung.whereclause !=""> and ${pruefung.whereclause} </#if>\
group by ${groupbycol.fieldname}\
;\
\
</#if> --vom prio-Filter\
</#foreach>\
\
insert into tmp_abgleich\
(zeitraum,\
--prio,\
ord,\
pruefung,\
comparison,\
result_table_1,\
result_table_2,\
result_code\
)\
select zeitraum,\
ord,\
pruefung,\
comparison,\
sum(val(result_table_1)),\
sum(val(result_table_2)),\
1\
from tmp_abgleich_summen\
--where comparison='Summe'\
group by 1,2,3,4;\
\
update tmp_abgleich set result_code=0\
where val(result_table_2) =val(result_table_1);\
\
\
</#if> --wenn aggregation=Summen\
\
\
<#if aggregation=="2">\
--Datensätze:\
\
\
--nur in Tabelle 1, fehlt in Tabelle 2:\
insert into tmp_abgleich_ds\
(zeitraum ,\
pruefung,\
comparison,\
<#foreach idcol in idcols>\
${idcol.fieldname} ,\
</#foreach>\
result_table_1 ,\
--result_table_2 ,\
result_code )\
select T1.${groupbycol.fieldname},\
'Datensatz-Abgleich',\
'Existenz',\
<#foreach idcol in idcols>\
T1.${idcol.fieldname} ,\
</#foreach>\
'x',\
1 --Fehlt\
from tmp_table_1 T1 left outer join tmp_table_2 T2\
on (1=1 <#foreach idcol in idcols>\
and T1.${idcol.fieldname}=T2.${idcol.fieldname}\
</#foreach>\
)\
where T2.${groupbycol.fieldname} is null\
;\
--nur in Tabelle 2, fehlt in Tabelle 1:\
insert into tmp_abgleich_ds\
(zeitraum ,\
pruefung,\
comparison,\
<#foreach idcol in idcols>\
${idcol.fieldname} ,\
</#foreach>\
--result_table_1 ,\
result_table_2 ,\
result_code )\
select T1.${groupbycol.fieldname},\
'Datensatz-Abgleich',\
'Existenz',\
<#foreach idcol in idcols>\
T1.${idcol.fieldname} ,\
</#foreach>\
'x',\
1 --Fehlt\
from tmp_table_2 T1 left outer join tmp_table_1 T2\
on (1=1 <#foreach idcol in idcols>\
and T1.${idcol.fieldname}=T2.${idcol.fieldname}\
</#foreach>\
)\
where T2.${groupbycol.fieldname} is null\
;\
\
--in beiden Tabellen vorhanden:\
insert into tmp_abgleich_ds\
(zeitraum ,\
pruefung,\
comparison,\
<#foreach idcol in idcols>\
${idcol.fieldname} ,\
</#foreach>\
result_table_1 ,\
result_table_2 ,\
result_code )\
select T1.${groupbycol.fieldname},\
'Datensatz-Abgleich',\
'Existenz',\
<#foreach idcol in idcols>\
T1.${idcol.fieldname} ,\
</#foreach>\
'x',\
'x',\
0 --vorhanden -> erfolgreich\
from tmp_table_1 T1 inner join tmp_table_2 T2\
on (1=1 <#foreach idcol in idcols>\
and T1.${idcol.fieldname}=T2.${idcol.fieldname}\
</#foreach>\
)\
;\
\
\
</#if> --von Aggregation=2\
\
<#if aggregation=="3">\
--felder:\
<#foreach field in fields>\
<#if field.priority!="P" && (field.priority==prio_filter || prio_filter=="")>\
\
<#assign ord=ord+1 />\
\
insert into tmp_abgleich\
(zeitraum,\
prio,\
ord,\
pruefung,\
comparison,\
fieldname,\
fieldcaption,\
result_table_1,\
result_table_2,\
result_code\
)\
select T1.${groupbycol.fieldname},\
'${field.priority}',\
${ord},\
'Feld-Abgleich',\
'Gleichheit',\
'${field.name}',\
'${field.caption}',\
T1.${field.name},\
T2.${field.name},\
(case when T1.${field.name}=T2.${field.name} or (T1.${field.name} is null and T2.${field.name} is null) then 0 \
else 1 end) as result_code\
from tmp_table_1 T1 left outer join tmp_table_2 T2\
on (1=1 <#foreach idcol in idcols>\
and T1.${idcol.fieldname}=T2.${idcol.fieldname}\
</#foreach>\
)\
where 1=1\
<#if "<<Zeitraum>>"!="">\
and T1.${groupbycol.fieldname}=<<Zeitraum>>\
</#if>\
;\
\
</#if> --vom prio-Filter\
\
</#foreach>\
</#if> --wenn aggregation=Felder\
\
\
\
\
update tmp_abgleich set result_code_str='Differenz',\
hidden_summe='SuperXmlTabelle?tid=37180&Profil=<<Profil>>&Zeitraum='||zeitraum||'&Feld='||fieldname||'&cachingcontrol=clearmask&navi=true' \
where result_code!=0;\
\
update tmp_abgleich set result_code_str='Erfolg'\
where result_code=0;\
\
drop table tmp_table_1;\
drop table tmp_table_2;\
\
<#if aggregation="1">\
select ord,\
pruefung,\
zeitraum,\
comparison,\
result_table_1,\
result_table_2,\
result_code_str,\
hidden_summe\
from tmp_abgleich\
where 1=1\
/* and <<Ausführungs-Status>>=result_code */\
order by 1;\
<#elseif aggregation=="2">\
\
update tmp_abgleich_ds set result_code_str='Differenz'\
where result_code!=0 or result_code is null;\
update tmp_abgleich_ds set result_code_str='Erfolg'\
where result_code=0;\
\
\
select \
pruefung,\
zeitraum,\
<#foreach idcol in idcols>\
${idcol.fieldname} ,\
</#foreach>\
result_table_1,\
result_table_2,\
result_code_str\
from tmp_abgleich_ds\
where 1=1\
/* and <<Ausführungs-Status>>=result_code */\
order by 1,2,3,4,5;\
\
<#elseif aggregation=="3">\
select ord,\
prio,\
pruefung,\
zeitraum,\
fieldname,\
fieldcaption,\
result_code_str,hidden_summe,count(*) as summe\
from tmp_abgleich\
where 1=1\
/* and <<Ausführungs-Status>>=result_code */\
group by 1,2,3,4,5,6,7,8\
order by 1,2,3,4;\
</#if>^--Freemarker Template\
\
<#assign aggregation="<<Aggregation des Vergleichs>>" />\
XIL List\
drop_and_delete movable_columns sizable_columns horizontal_scrolling\
white_space_color=COLOR_WHITE fixed_columns=2\
min_heading_height=35\
<#if aggregation="1">\
Column CID=0 heading_text="Nr." center_heading\
row_selectable col_selectable heading_platform readonly\
width=20 text_size=100\
Column CID=1 heading_text="Testfall" center_heading\
row_selectable col_selectable heading_platform readonly\
width=50 text_size=200\
Column CID=1 heading_text="${groupbycol.fieldcaption}" center_heading\
row_selectable col_selectable heading_platform readonly\
width=50 text_size=200\
Column CID=1 heading_text="Vergleich" center_heading\
row_selectable col_selectable heading_platform readonly\
width=50 text_size=200\
Column CID=1 heading_text="Wert ${profile.table_1_caption}" center_heading\
row_selectable col_selectable heading_platform readonly\
width=10 text_size=200\
Column CID=1 heading_text="Wert ${profile.table_2_caption}" center_heading\
row_selectable col_selectable heading_platform readonly\
width=10 text_size=200\
Column CID=1 heading_text="Status" center_heading\
row_selectable col_selectable heading_platform readonly\
width=10 text_size=200\
<#elseif aggregation="2">\
Column CID=1 heading_text="Testfall" center_heading\
row_selectable col_selectable heading_platform readonly\
width=50 text_size=200\
Column CID=1 heading_text="Zeitraum: ${groupbycol.fieldcaption}" center_heading\
row_selectable col_selectable heading_platform readonly\
width=50 text_size=200\
<#foreach idcol in idcols>\
Column CID=1 heading_text="Datensatz-ID\\000${idcol.fieldcaption}" center_heading\
row_selectable col_selectable heading_platform readonly\
width=10 text_size=200\
</#foreach>\
Column CID=1 heading_text="Vorhanden ${profile.table_1_caption}" center_heading\
row_selectable col_selectable heading_platform readonly\
width=10 text_size=200\
Column CID=1 heading_text="Vorhanden ${profile.table_2_caption}" center_heading\
row_selectable col_selectable heading_platform readonly\
width=10 text_size=200\
Column CID=1 heading_text="Status" center_heading\
row_selectable col_selectable heading_platform readonly\
width=10 text_size=200\
<#elseif aggregation="3">\
Column CID=0 heading_text="Nr." center_heading\
row_selectable col_selectable heading_platform readonly\
width=20 text_size=100\
Column CID=1 heading_text="Priorität" center_heading\
row_selectable col_selectable heading_platform readonly\
width=50 text_size=200\
Column CID=1 heading_text="Testfall" center_heading\
row_selectable col_selectable heading_platform readonly\
width=50 text_size=200\
Column CID=1 heading_text="${groupbycol.fieldcaption}" center_heading\
row_selectable col_selectable heading_platform readonly\
width=50 text_size=200\
Column CID=1 heading_text="Feldname" center_heading\
row_selectable col_selectable heading_platform readonly\
width=10 text_size=200\
Column CID=1 heading_text="Feldbezeichnung" center_heading\
row_selectable col_selectable heading_platform readonly\
width=10 text_size=200\
Column CID=1 heading_text="Ergebnis" center_heading row_selectable col_selectable heading_platform readonly width=10 text_size=20\
Column CID=1 heading_text="hidden_Summe" center_heading row_selectable col_selectableh eading_platform readonly width=10 text_size=20\
Column CID=1 heading_text="Summe" center_heading row_selectable col_selectableh eading_platform readonly width=1 text_size=1\
</#if>\
@@@^ ^ ^Generische Auswertung eines Tabellenabgleichs mit Link zu Details bei Auswertung mit Aggregation des Vergleichs=Felder^drop table tmp_abgleich; \
drop table tmp_abgleich_ds; \
drop table tmp_abgleich_summen;^^1^440^360^^1^^