Switching from DBget to DB

Hi All,

I’m using a dialplan script and noticed that I was getting warnings that DBget/DBput was depricated. So I’m trying to re-write the script, and I’d like to do this as smoothly as possible. So I currently have:

... exten => s,5,DBget(var1=FAMILY/KEY); exten => s,106,Goto(new_context,1); exten => s,6,Playback(whatever); ...

So far I’ve replaced it with the following, but I’m wondering if there is a more elegant way:

... exten => s,5,GotoIf(${DB_EXISTS(FAMILY/KEY)}?:new_context,1); exten => s,6,Set(var1=${DB_RESULT}); exten => s,7,Playback(whatever); ...
Is there a better way to do this? My biggest complaint is that I have to re-number the lines.

You have a $DB_RESULT but I don’t see where you are setting that. You don’t have to change your logic that much, and your gotoif is the wrong syntax http://www.voip-info.org/wiki-Asterisk+cmd+GotoIf

exten => s,n,GotoIf($["${DB(family/key)}" = ""]?new_context,1)
exten => s,n,Playback(whatever)

I didn’t test it but it should work. Did you look here http://www.voip-info.org/wiki-Asterisk+cmd+DBget

Please review the following function first:

voip-info.org/wiki/index.php … +db_exists