--Freemarker Template
--Achtung: Macro fügt Inhalte ein
--Bitte nur Freemarker Variablen füllen
<sqlvars>
<sqlvar name="sx_jobs_exists">select sp_table_exists('sx_jobs') from xdummy;</sqlvar>
</sqlvars>

<#assign jobs = [
{"uniquename":"21311-0002_stud_sem_da_geschl_hs", "caption":"Destatis Tabelle Stud. nach Geschl.+Staat einlesen", "filepath":"sxc/etl/genesis/21311-0002_stud_sem_da_geschl_hs/import.kjb","sachgebiete_id":360,
  "kenn_profil":"","hs_nr":"","modus_supported":1,"params":"",
"check_sql":"select count(*) from sxc_stud_sem_da_geschl_hs"}
] />




--- Freemarker Magic
<#if sx_jobs_exists=1>
<#foreach job in jobs>
delete from sx_jobs where uniquename='${job.uniquename}';
</#foreach>
  <#if SQLdialect='Postgres'>
   select sp_update_sequence('sx_jobs');
  </#if>
<#foreach job in jobs>
insert into sx_jobs (uniquename,caption,filepath,sachgebiete_id,kenn_profil,hs_nr,modus_supported,params
<#if SQLdialect='Postgres'>,check_sql
</#if>)
values ('${job.uniquename}','${job.caption}','${job.filepath}',${job.sachgebiete_id},<#if job.kenn_profil!="">${job.kenn_profil}<#else>null::integer</#if>,
<#if job.hs_nr!="">${job.hs_nr}<#else>null::integer</#if>,${job.modus_supported},'${job.params}'
<#if SQLdialect='Postgres'>
,'${job.check_sql}'
</#if>
);
</#foreach>

<#if SQLdialect='Postgres'>
   select sp_update_sequence('sx_jobs');
  </#if>
  
  </#if>
