Creating custom sqlite3 database... Asterisk 11

I have a situation where we have a growing list of CIDnum’s that get sent to a custom context via dialplan GotoIf. Rather than continually append each number to the GotoIf line in the dialplan (which is getting to be a mile long):
exten => _X.,n,GotoIf($[$["${ocn}" = “15555551212”] | ["${ocn}" = “15555551313”] | ["${ocn}" = “15555551414”] | ["${ocn}" = “15555551515”]…]?sub-custom,_X.,1)

We’d like to leverage Asterisk 11’s sqlite database and simply have the dialplan run a query on the database for the number, much like checking the existence of a number in the blacklist table:

exten => _X.,n,GotoIf(${BLACKLIST()}?blacklisted,s,1)

I realize the inherent risks of mucking with the astdb.sqlite file, but would like to know if it’s possible to create a custom database or add a custom table with the intent of querying it through the dialplan. Or if there is a better or other way of screening a bunch of numbers within the diaplan.

You could probably hack the caller ID name, setting the name=${ocn} temporarily, then run BLACKLIST(), and finally restore the caller ID name to the original value.

That’s a little sloppy. This might work better:

[code]exten => _X.,n,Set(ocnmatch=${DB_EXISTS(ocnlist/${ocn})}) ; BLACKLIST-like functionality
same => n,GotoIf( $["${ocnmatch}" = “1”]?sub-custom,${EXTEN},1)

asteriskCLI> dialplan reload
asterisk
CLI> database put ocnlist 5551234 notes
asteriskCLI> database put ocnlist 5555678 other.notes
asterisk
CLI> database show ocnlist[/code]

[quote=“penguinpbx”]…That’s a little sloppy. This might work better:

[code]exten => _X.,n,Set(ocnmatch=${DB_EXISTS(ocnlist/${ocn})}) ; BLACKLIST-like functionality
same => n,GotoIf( $["${ocnmatch}" = “1”]?sub-custom,${EXTEN},1)

asteriskCLI> dialplan reload
asterisk
CLI> database put ocnlist 5551234 notes
asteriskCLI> database put ocnlist 5555678 other.notes
asterisk
CLI> database show ocnlist[/code][/quote]

This should work perfectly! Thanks!