[SR-Users] "select count(*)" with avp_db_query always returns null

Andrade Ricardo (CI/AFU1) Ricardo.Keigo at br.bosch.com
Tue Jul 5 12:30:19 CEST 2011


Hi Daniel,

Code:
        sql_query("openserdb", "SELECT count(*) FROM subscriber where username='foo'", "ra");
        $avp(s:value) = $dbr(ra=>[0,0]);
        xlog("L_INFO", "avp(s:value)=$avp(s:value) (avp(s:value){s.int})=$(avp(s:value){s.int}) dbr(ra=>rows)=$dbr(ra=>rows)");
        sql_result_free("ra");

Output:
avp(s:value)= (avp(s:value){s.int})= dbr(ra=>rows)=1


I am testing only with kamailio-3.1.0 right now.

Mit freundlichen Grüßen / Best regards

Ricardo Keigo de Sales Andrade

Robert Bosch GmbH
 (CI/AFU)
Postfach 30 02 20
70442 Stuttgart
GERMANY
www.bosch.com

Tel. +49(711)811-3607004
Mobil +49(172)1081152
ricardo.andrade at br.bosch.com

Sitz: Stuttgart, Registergericht: Amtsgericht Stuttgart, HRB 14000;
Aufsichtsratsvorsitzender: Hermann Scholl; Geschäftsführung: Franz Fehrenbach, Siegfried Dais;
Stefan Asenkerschbaumer, Bernd Bohr, Rudolf Colm, Volkmar Denner, Wolfgang Malchow, Peter Marks, Uwe Raschke, Wolf-Henning Scheider, Peter Tyroller


-----Ursprüngliche Nachricht-----
Von: Daniel-Constantin Mierla [mailto:miconda at gmail.com]
Gesendet: Dienstag, 5. Juli 2011 12:21
An: SIP Router - Kamailio (OpenSER) and SIP Express Router (SER) - Users Mailing List
Cc: Andrade Ricardo (CI/AFU1)
Betreff: Re: [SR-Users] "select count(*)" with avp_db_query always returns null

Hello,

On 7/5/11 12:07 PM, Andrade Ricardo (CI/AFU1) wrote:
> Hi Daniel,
> Hi Alex,
>
> Thanks! That looks great. Once commited, I'll test it, too.
>
> By the way, I've just tried with sql_query. It didn't work as well. Do you think it is fixed together with Alex's change?
>
> Shouldn't there be a warning/error message if the returned data type is not supported?
>
>
> Code:
>          sql_query("openserdb", "SELECT count(*) FROM subscriber where username='foo'", "ra");
>          $avp(s:value) = $dbr(ra=>[0,0]);
>          xlog("L_INFO", "avp(s:value)=$avp(s:value)\n");
>            sql_result_free("ra");
>
> Output:
>            avp(s:value)=
interesting, I just looked in the code and bigints should be converted
to string values. Can you test if ($dbr(ra=>rows) >0) to be sure there
was a row returned by the query.

Cheers,
Daniel

--
Daniel-Constantin Mierla -- http://www.asipto.com
http://linkedin.com/in/miconda -- http://twitter.com/miconda




More information about the sr-users mailing list