后缀表达式计算器验证

时间:2015-11-05 11:28:58

标签: validation

我需要使用循环稍微编辑这段代码,告诉用户他们的输入不正确,然后让他们重新输入修复后的表达式?

select
  count (temptab.idhdok) as pocet,
  temptab.ucet_obd,
  temptab.dtzdanitpln,
  substring (temptab.podminky_text, 4,2) as podminky,
  temptab.jmeno_uziv,
  temptab.textpozn2,
  count(temptab.pracoviste) as prac,
  temptab.mnpracovniku,
  SUM(temptab.hdmzda_naklad_smena) as naklad,
  temptab.hdodpis_naklad_smena,
  (select count(*) from qsdok where (cis_zbozi = 'PROSTOJ 03.3' or cis_zbozi = 'PROSTOJ 07' or cis_zbozi = 'PROSTOJ 08' or cis_zbozi = 'PROSTOJ 10') and qsdok.idhdok=temptab.idhdok) as prostoje,
    (select sum(qhdok_udr.hdccenaval2)
     from qhdok_udr
       left join typdok on typdok.idtypdok = qhdok_udr.idtypdok
     where
       typdok.typ_dok = 'UDR' and
       qhdok_udr.podminky_text != 'UDRMECH' and
       qhdok_udr.ucet_obd like '%2015.09%' and
       qhdok_udr.cis_zbozi_pracovisteadd like temptab.pracoviste
  ) as hdudrzbapracoviste,
  (select sum(qhdok_udr.hdccenaval2)
     from qhdok_udr
       left join typdok on typdok.idtypdok = qhdok_udr.idtypdok
     where
       typdok.typ_dok = 'UDR' and
       qhdok_udr.podminky_text != 'UDRMECH' and
       qhdok_udr.ucet_obd like '%2015.09%' and
       (qhdok_udr.cis_zbozi_pracovisteadd like 'M%')
  ) as hdudrzbacelkem,
  (select sum(qhdok_udr.hdccenaval2)
     from qhdok_udr
       left join typdok on typdok.idtypdok = qhdok_udr.idtypdok
     where
       typdok.typ_dok = 'UDR' and
       qhdok_udr.podminky_text = 'UDRMECH' and
       qhdok_udr.ucet_obd like '%2015.09%' and
       qhdok_udr.cis_zbozi_pracovisteadd like temptab.pracoviste       
  ) as hdmechanikpracoviste,
  (select sum(qhdok_udr.hdccenaval2)
     from qhdok_udr
       left join typdok on typdok.idtypdok = qhdok_udr.idtypdok
     where
       typdok.typ_dok = 'UDR' and
       qhdok_udr.podminky_text = 'UDRMECH' and
       qhdok_udr.ucet_obd like '%2015.09%'
  ) as hdmechanikcelkem,
  sum(temptab.mnZmetky) as mnZmetky,
  sum(temptab.mnTuk) as mnTuk,
  sum(temptab.mnKukurice) as mnKukurice,
  sum(temptab.mnFolie) as mnFolie,
  sum(temptab.mnozstvi) as mnozstvi,
  sum(temptab.mnZmetky) * 24.7 as hdZmetky,
  sum(temptab.mnTuk) * 30 as hdTuk,
  sum(temptab.mnKukurice) * 10 as hdKukurice,
  sum(temptab.mnFolie) * 130 as hdFolie,
  sum((temptab.mnZmetky * 24.7)+(temptab.mnTuk * 30)+(temptab.mnKukurice * 10)+(temptab.mnFolie * 130)) as hdCelkem,
  sum((temptab.mnZmetky * 24.7)+(temptab.mnTuk * 30)+(temptab.mnKukurice * 10)+(temptab.mnFolie * 130)) / isnull(nullif(sum(temptab.mnozstvi),0),1) as hdKs
from
(select
  qhdok.idhdok,
  qhdok.ucet_obd,
  qhdok.dtzdanitpln,
  qhdok.podminky_text,
  qhdok.hdmzda_naklad_smena,
  qhdok.hdodpis_naklad_smena,
  pracoviste = case
    when qhdok.podminky_text like 'KB%'  then 'MKB'
    when qhdok.podminky_text like '2UP%' then 'MUP'
    when qhdok.podminky_text like 'M3%'  then 'M3'
    when qhdok.podminky_text like 'PUK%' then 'PUK'
    when qhdok.podminky_text like 'M1%' then 'M1'
    when qhdok.podminky_text like 'M2%' then 'M2'   
    else ''
  end,
  qhdok.jmeno_uziv,
  qhdok.mnpracovniku,
  isnull((select sum(HDHDOKPOZNCISLO) from qhdokpozn where qhdokpozn.idhdok = qhdok.idhdok and qhdokpozn.KODTHDOKPOZN like 'VYRZMP'),0)  as mnZmetky,
  isnull((select sum(HDHDOKPOZNCISLO) from qhdokpozn where qhdokpozn.idhdok = qhdok.idhdok and qhdokpozn.KODTHDOKPOZN like 'VYRZMT'),0)  as mnTuk,
  isnull((select sum(HDHDOKPOZNCISLO) from qhdokpozn where qhdokpozn.idhdok = qhdok.idhdok and qhdokpozn.KODTHDOKPOZN like 'VYRZMK'),0)  as mnKukurice,
  isnull((select sum(HDHDOKPOZNCISLO) from qhdokpozn where qhdokpozn.idhdok = qhdok.idhdok and qhdokpozn.KODTHDOKPOZN like 'VYRZMF'),0)  as mnFolie,
  isnull((select top 1 cast(HDOKPOZNMEMO as varchar(max))  from qhdokpozn where qhdokpozn.idhdok = qhdok.idhdok and qhdokpozn.KODTHDOKPOZN like 'VYRPOZ'),'') as textpozn2,
  isnull((select sum(dbo.fn_UO_mnPocetvAltMJ(qsdok.idzbozi, null, null, 'KS', qsdok.mncelkempocet)) from qsdok where qsdok.idhdok = qhdok.idhdok and qsdok.kod_pohyb ='P30' and qsdok.mncelkempocet>0 and
                    (qsdok.slozka_ident not like 'pmic%') and charindex('MIX',qsdok.nazev_zbozi)=0 and qsdok.cis_zbozi not like 'PROSTOJ%' and qsdok.cis_zbozi != 'POPCORN' ),0) as mnozstvi
 from qhdok_smena qhdok
 where qhdok.typ_dok = 'SPU' and (qhdok.idhdok_vzor = 41875 or qhdok.idhdok_vzor = 239530) and qhdok.ucet_obd like  '%2015.09%' and qhdok.podminky_text like '%%%'+'%' and (qhdok.podminky_text like 'M3%' or qhdok.podminky_text like '2UP%' or qhdok.podminky_text like 'KB%' or qhdok.podminky_text like 'M1%' or qhdok.podminky_text like 'M2%')

-- qhdok.idhdok,qhdok.ucet_obd, qhdok.idhdok, qhdok.dtzdanitpln,qhdok.podminky_text, qhdok.hdmzda_naklad_smena, qhdok.hdodpis_naklad_smena, qhdok.jmeno_uziv, qhdok.textpozn2, qhdok.mnpracovniku
) temptab
group by  temptab.idhdok, temptab.ucet_obd, temptab.dtzdanitpln, temptab.pracoviste, substring (temptab.podminky_text, 4,2), temptab.jmeno_uziv, temptab.textpozn2, temptab.mnpracovniku, temptab.hdodpis_naklad_smena, temptab.hdmzda_naklad_smena

它需要使用'System.out.println'进行某种消息输出,告诉用户他们的类型不正确

0 个答案:

没有答案