--todo 20765.20

update WEBMENUDIALOG_DESC wmdd set wmdd.description = 
(select t.descr from
   (select wmd.webmenudialog_id, l.language_id, l.code,
       (select 
          (case (substr(l.code,1,2))
            when 'DK' then nvl(d.dkdescription, d.endescription)
            when 'FR' then nvl(d.frdescription, d.endescription)
            when 'DE' then nvl(d.gedescription, d.endescription)
            when 'NL' then nvl(d.nldescription, d.endescription)
            else d.endescription end)
          from dialogs d
         where d.dialog_id = wmd.dialog_id) descr
    from webmenudialog wmd, languages l
    where l.translatedescription = 'Y') t 
  where wmdd.webmenudialog_id = t.webmenudialog_id 
       and wmdd.language_id = t.language_id)
where ((wmdd.description='-' and  substr((select l.code from languages l where l.language_id = wmdd.language_id),1,2)  in ('EN','NL','DE')) or
       (wmdd.description='FR' and  substr((select l.code from languages l where l.language_id = wmdd.language_id),1,2) ='FR') or
       (wmdd.description='DK' and  substr((select l.code from languages l where l.language_id = wmdd.language_id),1,2) ='DK'));

commit;
