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
|
--//---------------------------------------------------------------------------------------------------------------------------
FUNCTION TOKEN_COUNT(chaine_token IN VARCHAR2,separateur IN VARCHAR2)
RETURN INTEGER
IS
token_count INTEGER:=0;
BEGIN
FOR scan IN 1..LENGTH(chaine_token)
LOOP
IF SUBSTR(chaine_token,scan,1)=separateur THEN
token_count:=token_count+1;
END IF;
END LOOP;
RETURN token_count;
END TOKEN_COUNT;
--//-----------------------------------------------------------------------------------------------------------
FUNCTION TOKEN_AT(chaine IN VARCHAR2,separateur IN VARCHAR2,token_at IN INTEGER)
RETURN VARCHAR2
IS
position_depart INTEGER;
position_fin INTEGER;
token_compte INTEGER;
longueur_extraire INTEGER;
token_extrait VARCHAR2(250);
BEGIN
token_compte:=TOKEN_COUNT(chaine,separateur);
IF token_at=1 THEN
position_depart:=1;
ELSE
position_depart:=INSTR(chaine,separateur,1,token_at-1)+1;
END IF;
IF token_at=token_compte+1 THEN
position_fin:=length(chaine)+1;
ELSE
position_fin:=INSTR(chaine,separateur,1,token_at);
END IF;
longueur_extraire:=position_fin-position_depart;
IF longueur_extraire=0 THEN
longueur_extraire:=1;
END IF;
token_extrait:=SUBSTR(chaine,position_depart,longueur_extraire);
RETURN token_extrait;
END TOKEN_AT; |
Partager