[Home]

Summary:ASTERISK-06984: func_odbc write values missing
Reporter:Daniel Mikusa (dmikusa)Labels:
Date Opened:2006-05-16 13:14:20Date Closed:2006-05-16 16:15:11
Priority:MinorRegression?No
Status:Closed/CompleteComponents:Functions/func_odbc
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:
Description:When running an SQL write query with multiple values, values other than the first are missing.

Example:

extensions.conf
exten => 2,n,Answer()
exten => 2,n,Set(ODBC_LOG_DATA()=1,asdf)
exten => 2,n,Hangup()

func_odbc.conf
[LOG_DATA]
dsn=asterisk
write=INSERT INTO data (id, data) VALUES ('${VAL1}', '${VAL2}')

Upon execution, the record inserted is (1,'').


****** ADDITIONAL INFORMATION ******

If you change func_odbc.conf to

[LOG_DATA]
dsn=asterisk
write=INSERT INTO data (id, data) VALUES ('${VALUE}', '${VALUE}')

Where ${VALUE} is the entire value string.

The record (1,1) is inserted.
Comments:By: Tilghman Lesher (tilghman) 2006-05-16 14:39:55

As noted in the sample configuration file, please backslash your commas, as extensions.conf translated non-escaped commas into pipes.  This is then interpreted by the Set application as a second argument, which is why the function never receives the argument.

Not a bug.

By: Daniel Mikusa (dmikusa) 2006-05-16 15:04:56

Unfortunatly that doesn't seem to fix the problem.  I apologize for not mentioning that I had already tried that previously.

exten => 2,n,Set(ODBC_LOG_DATA()=asdf\,1)

produces the SQL statment

INSERT INTO data (id, data) VALUES ('asdf,1', '')

Also the func_odbc.conf file doesn't mention backslashing commas.  It mentions, escaping single ticks, but not commas.

By: Tilghman Lesher (tilghman) 2006-05-16 16:14:37

Hmmm, a janitor patch in the pipeline wasn't committed, and I thought it already was.  Fixed.

By: hristo (hristo) 2006-05-16 16:14:56

I have experienced the same problem. A quick workaround is to use ${ARGn} instead of ${VALn} to insert more than one value in the SQL statement like that:

Set(ODBC_LOG_DATA(asdf,qwer,zxcv)=1)

and have the following line in func_odbc.conf:

write=INSERT INTO data (id, data1, data2, data3) VALUES ('${VAL1}', '${ARG1}', '${ARG2}', '${ARG3}')

This worked for me and solved my problem. I completely forgot to report it as bug though...