TT#76457 lnp_number lookup

Change-Id: Icfe6c6aa52f20810aaf4b4bbcf519b1a453e1081
(cherry picked from commit 60cf0621d1)
changes/04/38104/1
Rene Krenn 5 years ago
parent 69bcc06e14
commit ba227fcd5d

@ -0,0 +1,4 @@
SET sql_log_bin=0;
use billing;
drop function get_lnp_number_id;

@ -0,0 +1,38 @@
SET sql_log_bin=0;
use billing;
delimiter ;;
create function get_lnp_number_id(
_destination varchar(511),
_epoch decimal(13,3)
) returns int(11)
deterministic reads sql data
begin
declare _destination_prefix varchar(511);
declare _i int(3);
declare _number_id int(11);
set _i = length(_destination);
destination_loop: loop
if _i < 0 or _number_id is not null then
leave destination_loop;
end if;
set _destination_prefix = substr(coalesce(_destination,""),1,_i);
set _number_id = (select id from billing.lnp_numbers
use index (number_idx)
where number = _destination_prefix
and (start <= from_unixtime(_epoch) or start is null)
and (end > from_unixtime(_epoch) or end is null)
limit 1);
set _i = _i - 1;
end loop destination_loop;
return _number_id;
end;;
delimiter ;
Loading…
Cancel
Save