<div dir="ltr">Hello Камиль<div><br></div><div style>Thank you so much for your response. Basically, what I have done is created a table `dr_rates`:</div><div style><br></div><div style><div>+--------+----------------------------------------+--------+--------------+----------+------------------+-------------+----------+</div>
<div>| rateid | destination | cc | prefix | listrate | retailrate | currency | carrier |</div><div>+--------+----------------------------------------+--------+--------------+----------+------------------+--------------+---------+</div>
<div>| 5839 | Canada 416 Metro Toronto | 1 | 1416 | 0.0028 | 0.00364 | USD | TN1 <span class="" style="white-space:pre">         </span>|</div><div>+--------+----------------------------------------+--------+--------------+----------+------------------+--------------+---------+</div>
<div><br></div><div style>And in `dr_rules`</div><div style><br></div><div style><div>+---------+-----------+--------+---------+--------------+---------+--------+-------------+------------------------------------------------------+</div>
<div>| ruleid | groupid | prefix | timerec | priority | routeid | gwlist | attrs | description |</div><div>+---------+-----------+--------+---------+--------------+---------+--------+-------------+-------------------------------------------------------+</div>
<div>| 5839 | 0 | 1416 | | 1 | 0 | | yes | Route for Canada 416 Metro Toronto |</div><div>+---------+-----------+--------+---------+--------------+---------+--------+-------------+-------------------------------------------------------+</div>
<div><br></div></div></div><div style><br>For scalability reasons as mentioned with Muhammad, we would like on every call to fire a perl script that would</div><div style>query the database, and pull all the prefix for the dialled number order by price ascending. I don't know much about</div>
<div style>prefixes and types of tricks carrier like to play longest vs. shortest matching etc however, what I am thinking about is:</div><div style><br></div><div style><br></div><div style>1) Pull up all records for the dialed CC</div>
<div style>2) If CC is 1 digit substring the first four digits of prefix</div><div style>2) If CC is 2 digits substring the first five digits of prefix<br></div><div style>2) If CC is 3 digits substring the first six digits digits of prefix<br>
</div><div style><br></div><div style>From all those relevant records, order by price ascending.</div><div style><br></div><div style>If the gateway for least expensive route fails, try the next route etc...</div><div style>
<br></div><div style>Nice and simple I think? If anyone feels there is anything wrong with this, I would really</div><div style>appreciate your input. Also, if anyone can write this perl script easily, I would be happy</div>
<div style>to compensate for it.</div><div style><br></div><div style>Kind Regards,</div><div style><br></div><div style>Nick.</div></div>