Project

General

Profile

2788

SQL Sprint
22/04/2025

create or replace procedure PBH_2B_VACH(b_nv varchar2,b_gcn out varchar2,b_loi out varchar2)
AS
    b_i1 number;
begin
-- Dan - Tra so trong chuoi dang ky
b_loi:='loi:Loi xin so GCN:loi';
b_gcn:=' ';
select count(*) into b_i1 from bh_2b_vach where nv=b_nv;
if b_i1<>0 then
    select stt into b_i1 from bh_2b_vach where nv=b_nv for update wait 10;
    if b_i1<>0 then
        b_i1:=b_i1+1;
        update bh_2b_vach set stt=b_i1 where nv=b_nv;
        b_gcn:='EA' || to_char(b_i1);
    end if;
end if;
b_loi:='';
exception when others then if b_loi is null then raise PROGRAM_ERROR; else null; end if;
end;

/

create or replace procedure PBH_XE_VACH(b_nv varchar2,b_gcn out varchar2,b_loi out varchar2)
AS
    b_i1 number;
begin
-- Dan - Tra so trong chuoi dang ky
b_loi:='loi:Loi xin so GCN:loi';
b_gcn:=' ';
select count(*) into b_i1 from bh_xe_vach where nv=b_nv;
if b_i1<>0 then
    select stt into b_i1 from bh_xe_vach where nv=b_nv for update wait 10;
    if b_i1<>0 then
        b_i1:=b_i1+1;
        update bh_xe_vach set stt=b_i1 where nv=b_nv;
        b_gcn:='EB'||to_char(b_i1);
    end if;
end if;
b_loi:='';
exception when others then if b_loi is null then raise PROGRAM_ERROR; else null; end if;
end;
 

Files