INSERT INTO ipedi.ped(
ped_codigo,
ped_numped, 
ped_rcacod, 
ped_dtlan, 
ped_importado, 
ped_clicod, 
ped_filcod, 
ped_cobcod, 
ped_plpgcod, 
ped_tvcod, 
ped_numpedcli, 
ped_obs, 
ped_vltotal, 
ped_canal, 
ped_dttrans, 
ped_versao, 
ped_obsenvio, 
ped_lpcod, 
ped_vlipi, 
ped_vlst,
ped_demander_b2b)
values(
coluna[1],--ped_codigo
coluna[2],--ped_numped 
coluna[10],--coluna[27],--ped_rcacod 
coluna[15],--ped_dtlan, 
1,--ped_importado, 
coluna[7],--ped_clicod, 
coluna[6],--ped_filcod, 
coluna[3],--ped_cobcod, 
coluna[4],--ped_plpgcod, 
coluna[25],--ped_tvcod, 
coluna[14],--ped_numpedcli, 
coluna[21],--ped_obs, 
coluna[32],--ped_vltotal, 
'F',--ped_canal, 
now(),--ped_dttrans, 
1,--ped_versao, 
'ENVIADO PELO DEMANDER',--ped_obsenvio, 
coluna[9],--ped_lpcod, 
coluna[34],--ped_vlipi, 
coluna[35],--ped_vlst
'S' --ped_demander_b2b
)
ON CONFLICT ON CONSTRAINT pk_ped
do
UPDATE SET 
ped_numped=EXCLUDED.ped_numped, 
ped_rcacod=EXCLUDED.ped_rcacod, 
ped_dtlan=EXCLUDED.ped_dtlan, 
ped_clicod=EXCLUDED.ped_clicod, 
ped_filcod=EXCLUDED.ped_filcod, 
ped_cobcod=EXCLUDED.ped_cobcod, 
ped_plpgcod=EXCLUDED.ped_plpgcod, 
ped_tvcod=EXCLUDED.ped_tvcod, 
ped_numpedcli=EXCLUDED.ped_numpedcli, 
ped_obs=EXCLUDED.ped_obs, 
ped_vltotal=EXCLUDED.ped_vltotal, 
ped_obsenvio=EXCLUDED.ped_obsenvio, 
ped_lpcod=EXCLUDED.ped_lpcod, 
ped_vlipi=EXCLUDED.ped_vlipi, 
ped_vlst=EXCLUDED.ped_vlst,
ped_demander_b2b=EXCLUDED.ped_demander_b2b

REGISTRO[16]
ExecutarScriptSempre
