Convert DBGet() to 1.2 ${DB()} line for line


#1

Hi,

I am planning how I am going to upgrade my 1.0.X code to 1.2.X.

Since I don’t want to change the old line numbers, I want to code a line-for-line replacement for DBGet.

will this work?

[code]; Asterisk 1.0.X
exten => s,1 DBGet(key=MyFamily/MyKey)
exten => s,2 NoOp(key exists)

exten => s,102 NoOp(key does not exist)

; Asterisk 1.2.X
exten => s,1 GotoIf($[“key=${DB(MyFamily/MyKey)}” = “”]?102) ; ??? Does this work ???
exten => s,2 NoOp(key exists)

exten => s,102 NoOp(key does not exist)[/code]If not, is there a line for line replacement that will work?

Thanks,

Lonnie


#2

Lonnie

Great question. The closest ‘old-style’ replacement is:

[code]; Asterisk 1.2.X
exten => s,1,GotoIf($[${DB_EXISTS(MyFamily/MyKey)} = 0]?102)
exten => s,2,NoOp(MyKey is: ${DB_RESULT})

exten => s,102,NoOp(key does not exist)[/code]If you can’t use ${DB_RESULT} as your variable for some reason (like it needs to persist after other DB commands) you can do a:

exten => s,2,Set(key=${DB_RESULT})but your line-for-line requirement is broken.

Lonnie