As the title says, I need to make a data comparison. The situation arises in the following way. I have a function that receives a parameter that parameter will be processed to remove certain characters from it.
The function is as follows:
CREATE OR REPLACE FUNCTION fReemplazaCeros(cPoliza IN VARCHAR2)
RETURN VARCHAR2
IS
retorno VARCHAR2 (50);
contador INTEGER (10);
BEGIN
contador := 1;
WHILE SUBSTR(cPoliza, contador, contador) = 0 LOOP
contador := contador + 1;
dbms_output.put_line('-> ' || SUBSTR(cPoliza, contador));
retorno:= SUBSTR(cPoliza, contador);
END LOOP;
RETURN retorno;
END;
Basically what happens with this function is that a string is going to be checked character by character in search of finding a 0 in said chain, so that at the end of everything, all the zeros that are in this chain ( in principle) be removed.
When I do tests with this function, the following comes up:
SELECT fREEMPLAZACEROS('00000273623413') FROM DUAL;
-> 0000273623413
-> 000273623413
-> 00273623413
This function could be said to work half-heartedly, since it only finds three 0's and leaves the while cycle, the question is Is there something wrong in this function that causes the cycle to come out?