[Freeswitch-users] Some help with my post-paid billing project
Diego Viola
diego.viola at gmail.com
Wed Oct 14 01:42:13 PDT 2009
DB[:rates].where(:prefix => substring('number', 1, length(prefix)).first
Rather.
On Wed, Oct 14, 2009 at 8:28 AM, Diego Viola <diego.viola at gmail.com> wrote:
> Nice, I just converted this to Ruby/Sequel.
>
> DB[:rates].first{{prefix=>substring('number', 1, length(prefix))}}
>
> Thanks for the help :).
>
>
> On Wed, Oct 14, 2009 at 2:07 AM, TTNC - Adnan Barakat <
> technical at ttnc.co.uk> wrote:
>
>> Diego Viola wrote:
>> > I'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?
>> >
>> > Any examples?
>> SELECT * FROM rates WHERE prefix = SUBSTRING('$NUMBER$', 1,
>> LENGTH(prefix)) LIMIT 1
>>
>> Adnan
>>
>> > Diego
>> >
>> > On Tue, Oct 13, 2009 at 10:45 PM, Even André Fiskvik <grevenx at me.com
>> > <mailto:grevenx at me.com>> wrote:
>> >
>> > What database are you using?
>> > You could do this with regular SQL, but it would by a costly
>> operation,
>> > for PostgreSQL we're using the prefix module:
>> > http://pgfoundry.org/projects/prefix/
>> >
>> > You can then match the closest prefix by using something like
>> > "WHERE myprefix_col @> caller_destination_number ORDER BY LENGTH
>> > (myprefix_col::text) LIMIT 1;"
>> >
>> >
>> > Best regards,
>> > Even André
>> >
>> >
>> > On 13. okt. 2009, at 23.53, Diego Viola wrote:
>> >
>> > > Hello,
>> > >
>> > > I'm trying to write a post-paid billing script, I have the CDR on
>> my
>> > > database and also a "rates" table, the CDR contains fields like
>> > > caller_destination_number, variable_duration, etc. and the rates
>> > > table contains: destination, prefix, rate (cost).
>> > >
>> > > The problem is that I can't just strip the destination number to
>> > > take the prefix from it because I have to deal with destination
>> > > numbers from different countries and they all have different
>> prefix
>> > > lengths... so I need to find another way to take the prefix from
>> the
>> > > destination number.
>> > >
>> > > Any ideas how to do this?
>> > >
>> > > Thanks,
>> > >
>> > > Diego
>> > >
>> > > _______________________________________________
>> > > FreeSWITCH-users mailing list
>> > > FreeSWITCH-users at lists.freeswitch.org
>> > <mailto:FreeSWITCH-users at lists.freeswitch.org>
>> > > http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>> > > UNSUBSCRIBE:
>> http://lists.freeswitch.org/mailman/options/freeswitch-
>> > > users
>> > > http://www.freeswitch.org
>> >
>> >
>> > _______________________________________________
>> > FreeSWITCH-users mailing list
>> > FreeSWITCH-users at lists.freeswitch.org
>> > <mailto:FreeSWITCH-users at lists.freeswitch.org>
>> > http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>> > UNSUBSCRIBE:
>> http://lists.freeswitch.org/mailman/options/freeswitch-users
>> > http://www.freeswitch.org
>> >
>> >
>> >
>> > ------------------------------------------------------------------------
>> >
>> > _______________________________________________
>> > FreeSWITCH-users mailing list
>> > FreeSWITCH-users at lists.freeswitch.org
>> > http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>> > UNSUBSCRIBE:
>> http://lists.freeswitch.org/mailman/options/freeswitch-users
>> > http://www.freeswitch.org
>>
>>
>> _______________________________________________
>> FreeSWITCH-users mailing list
>> FreeSWITCH-users at lists.freeswitch.org
>> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
>> http://www.freeswitch.org
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20091014/e9e17220/attachment-0002.html
More information about the FreeSWITCH-users
mailing list