[asterisk-users] FUNC_ODBC expr must be non-null

Eric Wieling EWieling at nyigc.com
Tue May 1 12:59:30 CDT 2012


If a value can EVER be empty, then you want to use quotes in your expressions.

exten => s,n,Set(torture.calls=${IF($["${torture.calls}"  = "1"]?2:1)})

-----Original Message-----
From: asterisk-users-bounces at lists.digium.com [mailto:asterisk-users-bounces at lists.digium.com] On Behalf Of Doug Lytle
Sent: Tuesday, May 01, 2012 1:56 PM
To: Asterisk Users Mailing List - Non-Commercial Discussion
Subject: [asterisk-users] FUNC_ODBC expr must be non-null

I'm slowly, but surely converting a 1.4.x dial-plan to an Asterisk 10.3.1 dial-plan, while also converting from mysql to func_odbc.  The part of my dial plan that handles the blacklisting of phone numbers reads as:

[tele_query]

exten => s,1,Set(torture.calls=0)
exten => s,n,Set(ARRAY(torture.phone,torture.calls,torture.name)=${ODBC_TORTURE_QUERY(${CALLERID(number)})})
exten => s,n,Set(torture.calls=${IF($[ ${torture.calls} = 1]?2:1)}) exten => s,n,Return()

The problem line is the 3rd Set.  What this line does (At least under 1.4.x) is, if the variable ${torture.calls} = 1, then change it to 2, if it has any other value, then change it to 1.

I initialize the torture.calls at the beginning of the subroutine, but when the query runs and there is no database entry, it returns null.

At that point, it fails.

Any suggestions on how to get func_odbc to either leave the initial value alone or is there a better way of handling this?

func_odbc.conf entry:

[TORTURE_QUERY]
dsn=MySQL-torture
readsql=SELECT phone, calls, name FROM TMP WHERE phone = ${ARG1}

Thanks!

Doug

-- 

Ben Franklin quote:

"Those who would give up Essential Liberty to purchase a little Temporary Safety, deserve neither Liberty nor Safety."



More information about the asterisk-users mailing list