I&#39;m using MySQL now but I will try PostgreSQL with the prefix module, is there a way to do that without the prefix module and with regular SQL?<br><br>Any examples?<br><br>Diego<br><br><div class="gmail_quote">On Tue, Oct 13, 2009 at 10:45 PM, Even André Fiskvik <span dir="ltr">&lt;<a href="mailto:grevenx@me.com">grevenx@me.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">What database are you using?<br>
You could do this with regular SQL, but it would by a costly operation,<br>
for PostgreSQL we&#39;re using the prefix module: <a href="http://pgfoundry.org/projects/prefix/" target="_blank">http://pgfoundry.org/projects/prefix/</a><br>
<br>
You can then match the closest prefix by using something like<br>
&quot;WHERE myprefix_col @&gt; caller_destination_number ORDER BY LENGTH<br>
(myprefix_col::text) LIMIT 1;&quot;<br>
<br>
<br>
Best regards,<br>
Even André<br>
<div><div></div><div class="h5"><br>
<br>
On 13. okt. 2009, at 23.53, Diego Viola wrote:<br>
<br>
&gt; Hello,<br>
&gt;<br>
&gt; I&#39;m trying to write a post-paid billing script, I have the CDR on my<br>
&gt; database and also a &quot;rates&quot; table, the CDR contains fields like<br>
&gt; caller_destination_number, variable_duration, etc. and the rates<br>
&gt; table contains: destination, prefix, rate (cost).<br>
&gt;<br>
&gt; The problem is that I can&#39;t just strip the destination number to<br>
&gt; take the prefix from it because I have to deal with destination<br>
&gt; numbers from different countries and they all have different prefix<br>
&gt; lengths... so I need to find another way to take the prefix from the<br>
&gt; destination number.<br>
&gt;<br>
&gt; Any ideas how to do this?<br>
&gt;<br>
&gt; Thanks,<br>
&gt;<br>
&gt; Diego<br>
&gt;<br>
</div></div>&gt; _______________________________________________<br>
&gt; FreeSWITCH-users mailing list<br>
&gt; <a href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</a><br>
&gt; <a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
&gt; UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-</a><br>
&gt; users<br>
&gt; <a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
<br>
<br>
_______________________________________________<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
</blockquote></div><br>