29062^Thema^20^0^0^100^200^1^integer^30^0^1^<<SQL>> select id, defaulttext from kb_topic order by 2;^^^
29065^Schlüsselwort^50^0^0^100^200^1^integer^30^0^1^<<SQL>> select id,defaulttext from kb_keyword order by 2;^^^
29060^Sachgebiet^1^0^0^100^200^1^integer^30^0^1^<<SQL>> select tid, name from sachgebiete order by 2;^ ^ ^
29060^Sachgebiet^1^0^0^100^200^1^integer^30^0^1^<<SQL>> select tid, name from sachgebiete order by 2;^ ^ ^
29064^Eingereicht von^40^0^0^100^200^1^integer^30^0^999^<<SQL>> select tid,name from userinfo where tid in (select distinct submitted_by from kb_chunk) order by 2;^^^
29061^Komponente^10^0^0^100^200^1^integer^30^0^1^<<SQL>> select tid, name from systeminfo order by 2;^ ^ ^
29061^Komponente^10^0^0^100^200^1^integer^30^0^1^<<SQL>> select tid, name from systeminfo order by 2;^ ^ ^
29062^Thema^20^0^0^100^200^1^integer^30^0^1^<<SQL>> select id, defaulttext from kb_topic order by 2;^ ^ ^
29064^Eingereicht von^40^0^0^100^200^1^integer^30^0^999^<<SQL>> select tid,name from userinfo where tid in (select distinct submitted_by from kb_chunk) order by 2;^ ^ ^
29065^Schlüsselwort^50^0^0^100^200^1^integer^30^0^1^<<SQL>> select id,defaulttext from kb_keyword order by 2;^ ^ ^
29066^Ticket^60^0^0^100^60^1^char^30^0^999^^ ^ ^
29067^Meldungsart^25^0^0^100^200^1^integer^30^0^1^<<SQL>> select id, defaulttext from kb_k_submission_type order by 2;^ ^<<SQL>> select id, defaulttext from kb_k_submission_type where hiskey_id='Q'^
29067^Meldungsart^25^0^0^100^200^1^integer^30^0^1^<<SQL>> select id, defaulttext from kb_k_submission_type order by 2;^ ^<<SQL>> select id, defaulttext from kb_k_submission_type where hiskey_id='Q'^
select unnest(string_to_array('${Stichwort}', ' ')) as part;\
\
</sqlvar>\
</sqlvars>\
</sqlvars>\
<@selectintotmp \
\
select="1::smallint as ord,C.id,K.hiskey_id as submission_type,K.defaulttext as submission_type_str, C.defaulttext,C.info_text,'../edit/kb/kb_chunk_view_detail.jsp|id=' || C.id as nextedit0,'../edit/kb/kb_chunk_edit.jsp|id=' || C.id as nextedit1,''::varchar(255) as nextedit2,''::varchar(255) as nextedit3"\
-- create table tmp_k_chunk;\
source="kb_chunk C left outer join kb_k_submission_type K on (C.submission_type=K.id)"\
-- Schleife über split_search\
target="tmp_k_chunk">\
-- bei jedem treffer select 1 as count\
-- Zähle Datensätze in tmp_k_chunk, gruppiere nach id\
--> Ausgabe nach meisten Treffern\
\
create table tmp_k_chunk(\
id integer,\
submission_type varchar(255),\
submission_type_str varchar(255),\
defaulttext text,\
info_text text,\
nextedit0 varchar(255),\
nextedit1 varchar(255),\
nextedit2 varchar(255),\
nextedit3 varchar(255),\
score integer\
);\
\
<#assign count1=0>\
<#list split_search as p>\
<#assign count1=count1+1>\
<#assign count2=1>\
\
<#list split_search as p2>\
<#if (p2?index + 1) < split_search?size>\
<#assign count2=count2+1>\
\
<#if count1!=count2>\
insert into tmp_k_chunk\
select \
C.id,\
K.hiskey_id as submission_type,\
K.defaulttext as submission_type_str, \
C.defaulttext,\
C.info_text,\
'../edit/kb/kb_chunk_view_detail.jsp|id=' || C.id as nextedit0,\
'../edit/kb/kb_chunk_edit.jsp|id=' || C.id as nextedit1,\
''::varchar(255) as nextedit2,\
''::varchar(255) as nextedit3,\
${count2}-${count1}+1 as score\
from \
kb_chunk C \
left outer join kb_k_submission_type K \
on (C.submission_type=K.id)\
where 1=1\
where 1=1\
/* and C.sachgebiete_id=<<Sachgebiet>> */\
/* and C.sachgebiete_id=<<Sachgebiet>> */\
/* and C.systeminfo_id=<<Komponente>> */\
/* and C.systeminfo_id=<<Komponente>> */\
/* and C.submission_type=<<Meldungsart>> */ \
/* and C.submission_type=<<Meldungsart>> */ \
and (1=1 \
and (1=1 \
/* and (1!=1 or (lower(C.defaulttext) like lower('%<<Stichwort>>%')) */\
/* and (1!=1 --<<Stichwort>> */\
/* or (lower(C.longtext) like lower('%<<Stichwort>>%')) */\
or (lower(C.defaulttext) like lower('%' || array_to_string((string_to_array('<<Stichwort>>', ' '))[${count1}:${count2}], ' ') ||'%')) --<<Stichwort>> \
/* or (lower(C.info_text) like lower('%<<Stichwort>>%'))) */\
or (lower(C.longtext) like lower('%' || array_to_string((string_to_array('<<Stichwort>>', ' '))[${count1}:${count2}], ' ') ||'%')) --<<Stichwort>> \
or (lower(C.info_text) like lower('%' || array_to_string((string_to_array('<<Stichwort>>', ' '))[${count1}:${count2}], ' ') ||'%')) --<<Stichwort>> \
/* ) --<<Stichwort>> */\
)\
)\
/* and C.submitted_by=<<Eingereicht von>> */\
/* and C.submitted_by=<<Eingereicht von>> */\
/* and C.id in (select K.kb_chunk_id from kb_chunk2keyword K where K.kb_keyword_id=<<Schlüsselwort>>) */\
/* and C.id in (select K.kb_chunk_id from kb_chunk2keyword K where K.kb_keyword_id=<<Schlüsselwort>>) */\
/* and C.id in (select K.kb_chunk_id from kb_chunk2ticket K where K.ticket_id = <<Ticket>>) */\
/* and C.id in (select K.kb_chunk_id from kb_chunk2ticket K where K.ticket_id = <<Ticket>>) */\
</@selectintotmp>\
;\
<@informixnolog/>;\
</#if>\
</#if>\
</#list>\
</#list>\
\
<#foreach p in split_search>\
insert into tmp_k_chunk\
select \
C.id,\
K.hiskey_id as submission_type,\
K.defaulttext as submission_type_str, \
C.defaulttext,\
C.info_text,\
'../edit/kb/kb_chunk_view_detail.jsp|id=' || C.id as nextedit0,\
'../edit/kb/kb_chunk_edit.jsp|id=' || C.id as nextedit1,\
''::varchar(255) as nextedit2,\
''::varchar(255) as nextedit3,\
1 as score\
from \
kb_chunk C \
left outer join kb_k_submission_type K \
on (C.submission_type=K.id)\
where 1=1\
/* and C.sachgebiete_id=<<Sachgebiet>> */\
/* and C.systeminfo_id=<<Komponente>> */\
/* and C.submission_type=<<Meldungsart>> */ \
and (1=1 \
/* and (1!=1 --<<Stichwort>> */\
/* or (lower(C.defaulttext) like lower('%${p.part}%')) --<<Stichwort>> */\
/* or (lower(C.longtext) like lower('%${p.part}%')) --<<Stichwort>> */\
/* or (lower(C.info_text) like lower('%${p.part}%')) --<<Stichwort>> */\
/* ) --<<Stichwort>> */\
)\
/* and C.submitted_by=<<Eingereicht von>> */\
/* and C.id in (select K.kb_chunk_id from kb_chunk2keyword K where K.kb_keyword_id=<<Schlüsselwort>>) */\
/* and C.id in (select K.kb_chunk_id from kb_chunk2ticket K where K.ticket_id = <<Ticket>>) */\
;\
</#foreach>\
\
select \
id ,\
submission_type ,\
submission_type_str ,\
defaulttext ,\
info_text ,\
nextedit0 ,\
nextedit1 ,\
nextedit2 ,\
nextedit3 ,\
sum(score) as score\
into tmp_k_chunk2\
from tmp_k_chunk\
group by \
id ,\
submission_type ,\
submission_type_str ,\
defaulttext ,\
info_text ,\
nextedit0 ,\
nextedit1 ,\
nextedit2 ,\
nextedit3 \
order by score desc\
;\
\
drop table tmp_k_chunk;\
\
--submission_type an view übergeben:\
--submission_type an view übergeben:\
update tmp_k_chunk set nextedit0=nextedit0 || '&submission_type=problem'\
update tmp_k_chunk2 set nextedit0=nextedit0 || '&submission_type=problem'\
where submission_type='Q';\
where submission_type='Q';\
\
\
update tmp_k_chunk set nextedit0=nextedit0 || '&submission_type=loesung'\
update tmp_k_chunk2 set nextedit0=nextedit0 || '&submission_type=loesung'\
where submission_type='A';\
where submission_type='A';\
\
\
\
\
\
\
<@selectintotmp \
<@selectintotmp \
select="*"\
select="*"\
source="tmp_k_chunk"\
source="tmp_k_chunk2"\
target="tmp_k_chunk2">\
target="tmp_k_chunk3">\
where 1=1\
where 1=1\
order by ord,defaulttext,submission_type_str\
order by score desc,defaulttext,submission_type_str\