I have a function that converts the ID of a version to number, for example, from 1.0.0
to 10000
, so I can filter the results.
Function:
CREATE OR REPLACE FUNCTION f_convert_tag_to_number(ptag varchar2(12))
RETURN NUMBER IS
vretorno NUMBER(12);
BEGIN
SELECT ((regexp_substr(ptag,'[^.\D]+',1,1) * 10000) +
(regexp_substr(ptag,'[^.\D]+',1,2) * 100) +
(regexp_substr(ptag,'[^.\D]+',1,3) * 1))
INTO vretorno
FROM dual;
RETURN(vretorno);
END;
Inquiry:
SELECT r.tag
,f_convert_tag_to_number(r.tag)
FROM repositorio r
WHERE f_convert_tag_to_number(r.tag) BETWEEN
f_convert_tag_to_number('1.0.0') AND
f_convert_tag_to_number('1.5.0')
Problem, this example above query was just an example, I have a much larger query that uses this function about 15 times, and what I want is to reduce the use of the f_convert_tag_to_number
function
Does anyone know of any way?
Thank you