[asterisk-dev] extra parameter for DB read function

Julian Lyndon-Smith asterisk at dotr.com
Wed May 31 07:00:34 MST 2006


Hey, no bubble to burst - I'm always up for finding an easier way. I 
didn't realise that just by checking the existence of a pair it stored 
it in a variable.

OTOH it *is* more yeuch to read. All of those $ { [ are soooo easy to 
misplace, and sooo easy to misread and not find the problem.

And it is only 3 more lines of code :)

if no-one wants the patch, I'm more than happy to go with this method.

Thanks.

Julian.

Jared Smith wrote:
> On Wed, 2006-05-31 at 14:30 +0100, Julian Lyndon-Smith wrote:
>> There are often times that I want to read a DB value from the dialplan, 
>> and if this family/key pair does not exist, set it to some default value.
>>
>> for example:
>>
>> 1234,1 => Set(EMAILADDR=${DB(x/y)}
>> 1234,2 => GotoIf($["${EMAILADDR}" = ""]?3:4)
>> 1234,3 => Set(EMAILADDR=Someone at test.com)
>> 1234,4 => NoOp(${EMAILADDR})
>> 1234,5 => Hangup()
> 
> I hate to burst your bubble, but what's wrong with using the DB_EXISTS
> dialplan function?  
> 
> exten => 1234,1,Set(EMAILADDR=
> ${IF($[${DB_EXISTS(x/y)}]?${DB_RESULT}:Someone at test.com)})
> 
> Obviously it's a little harder to read (especially when all placed on
> one line), but it's already quite easy to use without adding more code
> to Asterisk.
> 
> -Jared
> 
> _______________________________________________
> --Bandwidth and Colocation provided by Easynews.com --
> 
> asterisk-dev mailing list
> To UNSUBSCRIBE or update options visit:
>    http://lists.digium.com/mailman/listinfo/asterisk-dev
> 
> 




More information about the asterisk-dev mailing list