[asterisk-users] ODBC dialplan looping problem

Dale Noll dnoll at wi.rr.com
Thu Apr 18 08:07:34 CDT 2013

A select that returns 0 rows does not always mean error.
If you make your SQL do a little more specific lookup, you can avoid the
loop entirely.

Instead of your:
readsql=SELECT pin from users WHERE confid='${SQL_ESC(${CONF_ID})}'

Something like:
readsql=select if(count(value)=0,0,1) from users where confid =
'${SQL_ESC(${ARG1})}' and pin = '${SQL_ESC(${ARG2})}'  ;

This will then take two arguments, the first is the conf id, the second is
the entered PIN.
It will return either 0 or 1.  1 if the pin and conf are a valid pair, 0 if

Then in dialplan, simply check the return value.

While your approach to getting the pin does work, I personnally would use
READ() as others have suggested.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20130418/44ed00ae/attachment.htm>

More information about the asterisk-users mailing list