[asterisk-dev] extra parameter for DB read function

Jared Smith jaredsmith at jaredsmith.net
Wed May 31 06:58:30 MST 2006


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




More information about the asterisk-dev mailing list