VALx Vs ARGx in func_odbc

hi guys,

can someone help me in understanding the different between VALx and ARGx in func_odbc.conf .
e.g below a SQL statement

writesql= delete from dtest where ID = ${ARG1}

this sql statment didnt work and was givin me that below error

[Jun 8 14:55:34] ERROR[8666][C-00000027]: pbx_functions.c:610 ast_func_read: Function ODBC_dtest cannot be read

and it did not work till I change it to VALx

take note I know the difference between calling a VALx and ARGx from dial plan, so I adjust my dial plan extension a
for the ARGx my call was like this

for the VALx my call was like this

To summarise
When I should know that I have to use ARGx and when I should use VALx?
Is the difference in name is to help us write better SQL query or there is a real difference of how asterisk deal with them

I doubt that using writesql with anything other than INSERT, UPDATE, or a procedure that does similar is really supported.

You appear to be reading when you have only defined a way of writing.

I would assume that VAL is what goes after the “=” in the Set(…) and ARG is what goes, in parentheses, before the =, for a Set, and as the only parameters of a function read.

so you wanna tell me that delete sql statement is not supported?

I imagine it would work, but it clearly doesn’t reflect the intended use of the feature.

I imagine you could use as readsql with

exten => ....n,Noop(${odbc_dtest(<key>))

or with writesql:

exten => ...,n,Set(odbc_dtest(<key>)=)

although I haven’t tried either, or done a detailed check of the code.

Even in read mode, Asterisk functions aren’t optimised for common sub-expressions, so there is no requirement that they don’t have side effects. Using write mode makes it clearer that there are side effects, but will require the provision of dummy value parameter.

My code actually work ,

what i was wondering why i force to use val in writsql and when i use arg instade it give me a error .

Because it a write, and therefore it needs something on the right hand side of the = to write! It does look like my Set won’t work, if it checks that you include something from the right hand side the equals in the final statement.

Set(obbc_dtest(<arg1>, <arg2>,....)=<val1>)

(I haven’t checked the syntax above on an actual system.)

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.