[OpenSIPS-Users] querying float point values in opensips-1.9 gives error

Jayesh Nambiar jayesh1017 at gmail.com
Wed Mar 13 15:45:54 CET 2013


Hi Vlad,
In this case I am actually calling a stored procedure inside avp_db_query()
function to query data from mysql. The stored procedure goes into multiple
tables and based on many conditions it gives the output. The datatypes of
the the columns in question are actually all DECIMAL(8,4) in the mysql
database.
Also in the procedure when the output variables are defined, they are
defined as DECIMAL(8,4), so I am sure its returning as DECIMAL format only
from the database to opensips. And it has been returning like this since
opensips version 1.6 till 1.8.2 :)

--- Jayesh




On Wed, Mar 13, 2013 at 3:11 PM, Vlad Paiu <vladpaiu at opensips.org> wrote:

> Hi Jayesh,
>
> The first thing that comes to mind is that you can cast your floats to
> string directly from the mysql query ( with something like cast(your_field
> as char) ).
> Could you please send us an example of the avp_db_query that was
> previously working, along with the 'show create table' for the table you
> are querying ?
>
> Feel free to change whatever relevant columns names, I just want to
> replicate this issue on my own machine :)
>
> Best Regards,
>
> Vlad Paiu
> OpenSIPS Developer
> http://www.opensips-solutions.**com <http://www.opensips-solutions.com>
>
>
>
> On 03/13/2013 04:56 AM, Ovidiu Sas wrote:
>
>> Make sure that the values are stored as strings in the table, not as
>> float.
>>
>> -ovidiu
>>
>> On Tue, Mar 12, 2013 at 10:40 PM, Jayesh Nambiar<jayesh1017 at gmail.com>
>>  wrote:
>>
>>> Hi Ovidiu,
>>> Thanks for your reply. But I just expect them to be stored as string in
>>> my
>>> AVPs. Even in 1.8.2, when I dumped those AVPs back into a database
>>> table, it
>>> always put the exact value like 1.0000 or 0.0123 etc. So it was indeed
>>> storing the entire value as string in the AVPs and not as 1 or 0. Is this
>>> behaviour changed now?
>>>
>>>
>>> --- Jayesh
>>>
>>>
>>> On Tuesday, March 12, 2013, Ovidiu Sas wrote:
>>>
>>>> You are trying to store a float into an int.  Prior to 1.9, there
>>>> wasn't a strict check on the conversion and whatever the result was,
>>>> it was stored (i.e. 1.000 was stored as 1 and 0.0123 was stored as 0).
>>>> For more info: http://linux.die.net/man/3/**strtol<http://linux.die.net/man/3/strtol>
>>>> Starting with 1.9, there is a strict check for invalid characters and
>>>> therefore the conversion fails: 1.000 and 0.0123 are not a valid
>>>> integers.
>>>>
>>>> Regards,
>>>> Ovidiu Sas
>>>>
>>>> On Tue, Mar 12, 2013 at 10:36 AM, Jayesh Nambiar<jayesh1017 at gmail.com>
>>>> wrote:
>>>>
>>>>> Hi,
>>>>> I am testing out Opensips-1.9 currently. While I was using
>>>>> opensips-1.8.2, I
>>>>> used avp_db_query to query some values from database tables which were
>>>>> float
>>>>> point values and used those values to insert into acc table. Obviously
>>>>> for
>>>>> billing reasons. But after upgrading to 1.9 it gives error.
>>>>> Eg: I am querying a table containing values 1.0000, 0.0123 etc. and
>>>>> storing
>>>>> it into AVPs. But the 1.9 version gives the following error:
>>>>> ERROR:core:db_str2int: Unexpected characters: [.0000]
>>>>> ERROR:db_mysql:db_mysql_**str2val: error while converting integer
>>>>> value
>>>>> from
>>>>> string
>>>>>
>>>>> Can someone help me to take corrective actions inorder to avoid these
>>>>> errors. Any help is much appreciated.
>>>>>
>>>>> Thanks,
>>>>>
>>>>> --- Jayesh
>>>>>
>>>> ______________________________**_________________
>> Users mailing list
>> Users at lists.opensips.org
>> http://lists.opensips.org/cgi-**bin/mailman/listinfo/users<http://lists.opensips.org/cgi-bin/mailman/listinfo/users>
>>
>
> ______________________________**_________________
> Users mailing list
> Users at lists.opensips.org
> http://lists.opensips.org/cgi-**bin/mailman/listinfo/users<http://lists.opensips.org/cgi-bin/mailman/listinfo/users>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20130313/a826cdf2/attachment.htm>


More information about the Users mailing list