1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
| procedure PARSE_EAN_BARCODE( BARCODE IN VARCHAR2)
as
v_barcode varchar2(500);
v_ean_id varchar2(2);
v_ean_data varchar2(50);
v_ean_lenght number(20);
oErrMsgr varchar2(50);
BEGIN
v_barcode :=barcode;
delete from ind_ean_barcode;
WHILE nvl(v_barcode,NULL) is not NULL
LOOP
v_ean_id:=substr(v_barcode,0,2);
v_barcode:=substr(v_barcode,3);
begin
select ean.ean_lenght into v_ean_lenght from ind_ean_norme ean where ean.ean_id=v_ean_id;
Exception
when no_data_found
-- erreur
then
oErrMsgr := 'Le code barre non conforme';
-- BREAK;
end;
--données à longueurs définies
if( v_ean_lenght > 0) then
v_ean_data:=substr(v_barcode,0,v_ean_lenght);
if (v_ean_id in (17,11))then
if(v_ean_data like '%00')then
v_ean_data:=to_date(substr(v_ean_data,0,5)||'1','YYMMDD');
else
v_ean_data:=to_date(v_ean_data,'YYMMDD');
end if;
end if;
--données à longueurs non définies
else
if(instr(v_barcode,'@')>0)then
v_ean_data:=substr(v_barcode,0,instr(v_barcode,'@')-1);
v_ean_lenght:=instr(v_barcode,'@');
else
v_ean_data:=v_barcode;
v_ean_lenght:=length(v_barcode);
end if;
end if;
v_barcode:=substr(v_barcode,v_ean_lenght+1);
--Enregistrement des données du code barre
begin
insert into ind_ean_barcode(ean_id , ean_data )
VALUES( v_ean_id,
v_ean_data);
end;
end loop;
end PARSE_EAN_BARCODE; |
Partager