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
not.

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.
--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
               http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users

Reply via email to