Jeremy
Jeremy

Reputation: 83

Asterisk phrase variables within variables?

I have a odd situation where I would like to phrase a variable inside an SQL string. Basically ODBC will return a query with a string, in that string there will be an Asterisk variable and I need that phrased and passed back to SQL. For example (pointless code but showing the example)-

exten => s,n,Set(QUERY=${ODBC_GET_QUERY(${EXTEN})}) 

The SQL query in func_odbc.conf is SELECT query FROM tablea WHERE number = ${ARG1}

Now QUERY will look like to = ${DIALED}, ${DIALED} being a asterisk variable (I will make it 17005551212 for example) I need that phrased so I end up with -

exten => s,n,Set(ALLOWED=${ODBC_GET_ALLOWED(${QUERY})})

The SQL query in func_odbc.conf would be SELECT allowed FROM tableb WHERE ${ARG1} so the SQL query would resolve to SELECT allowed WHERE to = 17005551212.

Before I dive into this and re-invent the wheel, is it possible or even allowed? I have actually not tried it yet. I know in a Set() statement it will phrase a variable inline, but is there a way to phrase variable that is in a variable when its returned via ODBC? Thanks!

Upvotes: 0

Views: 365

Answers (1)

arheops
arheops

Reputation: 15259

Please read carefully source code.

Func odbc use prepair call. So it will not work for your example just becuase prepair do not allow do that.

In general you can substitute variables. Example 1 WILL work ok.

Workaround - use mysql EXEC.

Upvotes: 1

Related Questions