Project

General

Profile

Xóa Công nợ tái

User documentation
23/04/2025

create or replace procedure PTBH_NHA_BH_CN_XOA_XOA(
    b_ma_dvi varchar2,b_nsd varchar2,b_so_id number,b_loi out varchar2)
AS
    b_l_ct varchar2(1); b_ngay_ht number; b_nha_bh varchar2(20);
    b_ma_nt varchar2(5); b_tien number; b_tien_qd number; b_nsd_c varchar2(10); b_so_id_kt number;
begin
select l_ct,ngay_ht,nha_bh,ma_nt,tien,tien_qd,nsd,so_id_kt into
    b_l_ct,b_ngay_ht,b_nha_bh,b_ma_nt,b_tien,b_tien_qd,b_nsd_c,b_so_id_kt
    from tbh_nha_bh_cn where so_id=b_so_id;
if b_nsd<>b_nsd_c then b_loi:='loi:Khong xoa chung tu nguoi khac:loi'; return; end if;
if b_so_id_kt<>0 then b_loi:='loi:Khong xoa chung tu da hach toan:loi'; return; end if;
b_loi:=PKH_MA_HAN_TEST(b_ma_dvi,b_ngay_ht,'BH','TA');
if b_loi is not null then return; end if;
PTBH_NHA_BH_CN_THOP(b_ma_dvi,b_l_ct,b_ngay_ht,b_nha_bh,b_ma_nt,-b_tien,-b_tien_qd,b_loi);
if b_loi is not null then return; end if;
delete tbh_nha_bh_cn where so_id=b_so_id;
b_loi:='';
exception when others then if b_loi is null then raise PROGRAM_ERROR; else null; end if;
end;
/
create or replace procedure PTBH_NHA_BH_CN_XOA
    (b_ma_dvi varchar2,b_nsd varchar2,b_pas varchar2,b_oraIn clob,b_comm varchar2:='C')
AS
    b_loi varchar2(100); b_so_id number;b_lenh varchar2(1000);
begin
-- Dan - Xoa tam ung
if b_comm='C' then
    b_loi:=FHT_MA_NSD_KTRA(b_ma_dvi,b_nsd,b_pas,'BH','TA','N');
    if b_loi is not null then raise PROGRAM_ERROR; end if;
end if;
b_lenh:=FKH_JS_LENH('so_id');
EXECUTE IMMEDIATE b_lenh into b_so_id using b_oraIn;
if b_so_id is null then b_loi:='loi:Nhap SO ID:loi'; raise PROGRAM_ERROR; end if;
PTBH_NHA_BH_CN_XOA_XOA(b_ma_dvi,b_nsd,b_so_id,b_loi);
if b_loi is not null then raise PROGRAM_ERROR; end if;
if b_comm='C' then commit; end if;
exception when others then if b_loi is null then raise PROGRAM_ERROR; else  raise_application_error(-20105,b_loi); end if;
end;

Files