Asterisk func db_exists

DB_EXISTS()

AstDB function to check if a key exists

Synopsis:

Check to see if a key exists in the Asterisk database

Description:

DB_EXISTS(<family>/<key>)

This function checks whether a key exists in the Asterisk database.
Checking for existence of a database key also sets the variable DB_RESULT to the key's value if it exists.

Return value

If the key exists, the function returns "1". If not, it returns "0".

Example

exten => s,1,Set(foo=${DB_EXISTS(cidname/7079994444)})

The following example can be used to replace the LookupBlacklist application. If there is a blacklist match it jumps to context "blacklisted" ext. s, priority 1:
exten => s,1,GotoIf(${DB_EXISTS(blacklist/${CALLERIDNUM})}?blacklisted,s,1)
exten => s,2,NoOp( ${CALLERIDNUM} not on Blacklist)
exten => s,3,Dial(SIP/......)

Notes


${CALLERIDNUM} seems to work only in 1.2; for 1.4, I used ${CALLERID(NUM)} instead.

CLI> show function DB_EXISTS

See also



DB_EXISTS()

AstDB function to check if a key exists

Synopsis:

Check to see if a key exists in the Asterisk database

Description:

DB_EXISTS(<family>/<key>)

This function checks whether a key exists in the Asterisk database.
Checking for existence of a database key also sets the variable DB_RESULT to the key's value if it exists.

Return value

If the key exists, the function returns "1". If not, it returns "0".

Example

exten => s,1,Set(foo=${DB_EXISTS(cidname/7079994444)})

The following example can be used to replace the LookupBlacklist application. If there is a blacklist match it jumps to context "blacklisted" ext. s, priority 1:
exten => s,1,GotoIf(${DB_EXISTS(blacklist/${CALLERIDNUM})}?blacklisted,s,1)
exten => s,2,NoOp( ${CALLERIDNUM} not on Blacklist)
exten => s,3,Dial(SIP/......)

Notes


${CALLERIDNUM} seems to work only in 1.2; for 1.4, I used ${CALLERID(NUM)} instead.

CLI> show function DB_EXISTS

See also



Created by: murf, Last modification: Sat 22 of Feb, 2014 (09:55 UTC) by khb
Please update this page with new information, just login and click on the "Edit" or "Discussion" tab. Get a free login here: Register Thanks! - Find us on Google+