C.13. DB_EXISTS()

DB_EXISTS(family/key)
Tests to see if a key exists in the AstDB. Returns 1 or 0. Sets the variable DB_RESULT to the value of the key, if it exists.
; Query if cidnums/4045559814 exists:
exten => 123,1,Set(foo=${DB_EXISTS(cidnums/4045559814)})
This is one way to replace the application LookupBlacklist(). This code example causes Asterisk to jump to the context blacklisted, extension s, priority 1, if the CID can be found in the blacklist:
exten => 123,1,GotoIf(${DB_EXISTS(blacklist/${CALLERID(num)})}?blacklisted,s,1)
exten => 123,n,Dial(IAX2/user:password@example.com/500)

[blacklisted]
exten => s,1,NoOp(${CALLERID(num)} is in the blacklist)
exten => s,n,Hangup()

Note

Internal help for this application in Asterisk 1.4:
  -= Info about function 'DB_EXISTS' =- 

[Syntax]
DB_EXISTS(<family>/<key>)

[Synopsis]
Check to see if a key exists in the Asterisk database

[Description]
This function will check to see if a key exists in the Asterisk
database. If it exists, the function will return "1". If not,
it will return "0".  Checking for existence of a database key will
also set the variable DB_RESULT to the key's value if it exists.
diff output to internal help in Asterisk 1.2:
- none -