[asterisk-users] func_odbc insert with mssql

Tilghman Lesher tilghman at mail.jeffandtilghman.com
Tue Aug 11 12:19:15 CDT 2009


On Tuesday 11 August 2009 11:33:30 David Budny wrote:
> I'm trying to use func_odbc to write to a MS SQL db.
>
> Here's my func_odbc conf:
>
> [OPTIN]
> dsn=MSSQL-Optin
> write=INSERT into OptIn (orgID) values (${VAL1})
>
> Dial Plan
>
> exten => +18665551212,n,Set(ODBC_OPTIN()=dave)
>
> When I do an odbc show, it shows that I am connected to the db. If I use
> isql, I can write to the db, however, when I use func_odbc, a record will
> not write.  I'm using asterisk 1.4.9. Any idea what might be wrong?

I suspect the problem is that you're missing the necessary quotes for
the string value of "dave".  Try, instead:

write=INSERT INTO OptIn (orgID) values ('${SQL_ESC(${VAL1})}')

MS SQL Server only permits you to leave the quotes off when you're
inserting a value into a numeric field.

-- 
Tilghman & Teryl
with Peter, Cottontail, Midnight, Thumper, & Johnny (bunnies)
and Harry, BB, & George (dogs)



More information about the asterisk-users mailing list