When I use xquery, I generally use it with a stored procedure that returns a value if not matched... so I always return at least one row with a variable of 'fail', -1, etc. to evaluate.

I like this for a variety of reasons (ie changing sql without changing the config)... but that being said...

Wouldn't this still work for you:

if($dbr(gateways=>rows)>0) { }

Fred Posner
The Palner Group, Inc.
503-914-0999 (direct)
954-472-2896 (fax)

On 04/05/2014 11:32 AM, Alex Balashov wrote:
Hi,

When using sql_xquery() like this:

    sql_xquery("ca", "SELECT * FROM gateways", "gateways");

... what's a good way to check if any rows were returned? Since one does
not have a $dbr(gateways=>rows) value in this scenario, what should one do?

- is_avp_set("$xavp(gateways=>id)")) does not appear to operate on
XAVPs, or at least, the fixup functions reject them:

ERROR: avpops [avpops.c:935]: fixup_is_avp_set(): bad attribute name
<$xavp(gateways=>id)>

- the 'defined' operator does not appear to return a negative condition
here:

    if(!defined $xavp(gateways=>id))

This condition evaluates to true.

Much appreciated!

-- Alex


_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users

Reply via email to