[asterisk-dev] NULL from MySQL database not NULL?

David Backeberg dbackeberg at gmail.com
Wed May 6 11:43:56 CDT 2009


On Wed, May 6, 2009 at 11:57 AM, Chris Maciejewski <chris at wima.co.uk> wrote:
> extensions.conf:
> exten => 601,1,MYSQL(Connect connid1 ${DBHOST} ${DBUSER} ${DBPASS} ${DBNAME})
> exten => 601,n,MYSQL(Query resultid1 ${connid1} SELECT some_null_col
> FROM table WHERE where id = 1)
> exten => 601,n,MYSQL(Fetch fetchid1 ${resultid1} X-DB-null)
> exten => 601,n,MYSQL(Clear ${resultid1})
> exten => 601,n,MYSQL(Disconnect ${connid1})
> exten => 601,n,NoOp(X-DB-nullt: ${X-DB-null})
> exten => 601,n,NoOp(ISNULL = ${ISNULL(${X-DB-null})})
>
> console:
>    -- Executing [601 at test:1] MYSQL("SIP/OpenSER-082cf100", "Connect
> connid1 mysql-ro asterisk pass1 test") in new stack
>    -- Executing [601 at test:2] MYSQL("SIP/OpenSER-082cf100", "Query
> resultid1 1 SELECT some_null_col FROM table WHERE where id = 1") in
> new stack
>    -- Executing [601 at test:3] MYSQL("SIP/OpenSER-082cf100", "Fetch
> fetchid1 2 X-DB-null") in new stack
>    -- Executing [601 at test:4] MYSQL("SIP/OpenSER-082cf100", "Clear 2")
> in new stack
>    -- Executing [601 at test:5] MYSQL("SIP/OpenSER-082cf100",
> "Disconnect 1") in new stack
>    -- Executing [601 at test:6] NoOp("SIP/OpenSER-082cf100", "X-DB-null:
> NULL") in new stack
>    -- Executing [601 at test:7] NoOp("SIP/OpenSER-082cf100", "ISNULL =
> 0") in new stack

This begs the question. Is the value of X-DB-null literally the word "NULL"?
How about some tacking this onto the end of your dialplan ...
exten => 601,n,Set(VALONE='')
exten => 601,n,Set(VALTWO=0)
exten => 601,n,Set(VALTHREE='NULL')
exten => 601,n,Set(VALFOUR=1)
exten => 601,n,NoOp("ISNULL(ONE) "${ISNULL(${VALONE}))
exten => 601,n,NoOp("ISNULL(TWO) "${ISNULL(${VALTWO}))
exten => 601,n,NoOp("ISNULL(THREE) "${ISNULL(${VALTHREE}))
exten => 601,n,NoOp("ISNULL(FOUR) "${ISNULL(${VALFOUR}))

My hunch is that of those, only VALONE should return non-zero from ISNULL.
But you'll know for sure soon. Try it out and let us know what you find.



More information about the asterisk-dev mailing list