DBget() vs ${DB()}


#1

I upgraded my system to Asterisk 1.2.7.1 last night. And I decided to read UPGRADE.txt to see if there was anything new.

Well I saw where it said that DBget() have been deprecated in favor of functions.

Well this is what I have in my extensions.conf:

exten => s,3,DBget(ATA=ata/${CALLERID(num)})

Which works fine for me, So I tried:

exten => s,3,Set(ATA=${DB(ata/${CALLERID(number)})})

and found that it did not work. I should also note I try using both ‘num’ and ‘number’ and neither one seem to work for me. It seems that the argument does not get expended out correctly. So I did the following:

exten => s,3,Set(KEY=${CALLERID(number)}
exten => s,4,Set(ATA=${DB(ata/${KEY})})

Key received the correct value, but again ATA did not get set at all. Note here ‘number’ worked fine.

Both of the FXO/FXS ATAs I use, if the caller ID is not passed will use the name of the ATA as the caller ID. So I check to see if they are in the database, if they are then I clear the ATA and continue with the privacy screen in the Dail(). If there is a callerID then I check it aginist a blacklist (again using a DBGet() ).

I like the DBGet() and don’t really understand why it is being . deprecated. But if the new method is to use ${DB()} then I will (as long as it will work, which right now it does not seem to be for me).


#2

WHat is the CLI output for the line, when it comes to the DB command ?


#3

When using

exten => s,3,DBget(ATA=ata/${CALLERID(num)})

I get:

[quote] – Executing DBget(“SIP/out-8647”, “ATA=ata/4085551212”) in new stack
– DBget: varname=ATA, family=ata, key=4085551212
– DBget: Value not found in database.
Apr 14 16:08:26 WARNING[17748]: ast_expr2.fl:183 ast_yyerror: ast_yyerror(): syntax error: syntax error, unexpected TOK_EQ, expecting TOK_MINUS or TOK_COMPL or TOK_LP or TOKEN; Input:
= 1
^
Apr 14 16:08:26 WARNING[17748]: ast_expr2.fl:187 ast_yyerror: If you have questions, please refer to doc/README.variables in the asterisk source.
[/quote]

And using:
exten => s,3,Set(ATA=${DB(ata/${CALLERID(number)})})

[quote] – Executing Set(“SIP/out-561b”, “ATA=”) in new stack
Apr 14 17:15:37 WARNING[18915]: ast_expr2.fl:183 ast_yyerror: ast_yyerror(): syntax error: syntax error, unexpected TOK_EQ, expecting TOK_MINUS or TOK_COMPL or TOK_LP or TOKEN; Input:
= 1
^
Apr 14 17:15:37 WARNING[18915]: ast_expr2.fl:187 ast_yyerror: If you have questions, please refer to doc/README.variables in the asterisk source.
[/quote]

and then:
exten => s,3,Set(KEY=${CALLERID(number)})
exten => s,4,Set(ATA=${DB(ata/${KEY})})

[quote] – Executing Set(“SIP/out-ea72”, “KEY=4085551212”) in new stack
– Executing Set(“SIP/out-ea72”, “ATA=”) in new stack
Apr 14 17:20:27 WARNING[19012]: ast_expr2.fl:183 ast_yyerror: ast_yyerror(): syntax error: syntax error, unexpected TOK_EQ, expecting TOK_MINUS or TOK_COMPL or TOK_LP or TOKEN; Input:
= 1
^
Apr 14 17:20:27 WARNING[19012]: ast_expr2.fl:187 ast_yyerror: If you have questions, please refer to doc/README.variables in the asterisk source.
[/quote]


#4

Ther eyou go, the key isnt found in the database, all following commands die therefore too.

See the first call to the DB giving you this result:

DBget: Value not found in database.

Load up a database GUI and check the table, something seems to be wrong there.

Have a SQL query log running and see what query asterisk is exactly sending to the DB.

Enter the SQL query in the editor by hand to check what is wrong.


#5

[quote=“RichardHH”]
Load up a database GUI and check the table, something seems to be wrong there.

Have a SQL query log running and see what query asterisk is exactly sending to the DB.

Enter the SQL query in the editor by hand to check what is wrong.[/quote]

I’m not using a SQL database. I’m just using the default Asterisk database (which I believe is the Sleeply Cat DB database).

As for doing the look-up. I will check it with the ${DB()} latter to see if it really is working (I need to use a phone which blocks the caller ID for testing and not my cell phone as I did when I generated the results).


#6

I had a chance to test it using a block callerID phone. And now I get:

[quote]-- Executing Set(“SIP/out-59a9”, “ATA=1”) in new stack
[/quote]

Which is what I wanted. Latter when I do the gotoif() test everything worked correctly.

Thank you for your help.


#7

[quote=“hematite”]I’m not using a SQL database. I’m just using the default Asterisk database (which I believe is the Sleeply Cat DB database).
[/quote]

DOH!
Sometimes…im such a moron :smiley: