Kreiranje statusa na dokumentima - nanovo

insert into tPA_SetDocTypeStat (acDocType, acStatus, acVerified, acName)

select g.acDocType, 'N', 'F', 'Nepotvrđen'

from tPA_SetDocType g

left join tPA_SetDocTypeStat t on g.acDocType = t.acDocType and acStatus = 'N'

where t.acDocType is null and t.acStatus is null

union all

select g.acDocType, 'P', 'T', 'Potvrđen'

from tPA_SetDocType g

left join tPA_SetDocTypeStat t on g.acDocType = t.acDocType and acStatus = 'P'

where t.acDocType is null and t.acStatus is null