viernes, 15 de febrero de 2019
Get Document No From AD_Table
-- select * from fnt_getdocumentno(319, 1000115);
-- select * from fnt_getdocumentno(472, 1000115);
-- select * from fnt_getdocumentno(318, 1000115);
create or replace function fnt_getdocumentno(p_table_id numeric(10,0), p_record_id numeric(10,0))
returns varchar
as $$
begin
return
(
case p_table_id
when 319 then
(select i.documentno from m_inout i
where i.m_inout_id = p_record_id)
when 472 then
(select i.documentno || '_' || il.line || '_' || mi.documentno from m_matchinv mi
join m_inoutline il
on mi.m_inoutline_id = il.m_inoutline_id
join m_inout i
on il.m_inout_id = i.m_inout_id
where mi.m_matchinv_id = p_record_id)
when 318 then
(select f.documentno from c_invoice f
where f.c_invoice_id = p_record_id)
end
);
end;
$$ language plpgsql;
Suscribirse a:
Enviar comentarios (Atom)
No hay comentarios:
Publicar un comentario