Insert into tHE_SetItem
create table m
(acIdent char (16),
acName char (80),
acUM char (3),
anFieldNA float,
anPrice decimal (18,2),
acFieldSA char (30))
select * from m
insert into em (em, naziv)
select distinct acUM, acUM from m where acUM not in (select em from em)
insert into tHE_SetItem (acIdent, acName, acUM, anFieldNA, anPrice, anPriceSupp, anBuyPrice, acFieldSA, acCurrency, acPurchCurr, acSetOfItem, acVATCode, anVAT)
select acIdent, acName, acUM, anFieldNA, case when anFieldNA > 0 then anPrice/anFieldNA else 0 end, case when anFieldNA > 0 then anPrice/anFieldNA else 0 end, case when anFieldNA > 0 then anPrice/anFieldNA else 0 end, acFieldSA,
'KM', 'KM', '13X', 'P1', 17 from m