[asterisk-users] func_odbc insert with mssql

David Budny dbudny at visiblecustomer.com
Tue Aug 11 14:58:34 CDT 2009



Date: Tue, 11 Aug 2009 12:19:15 -0500
From: Tilghman Lesher <tilghman at mail.jeffandtilghman.com>
Subject: Re: [asterisk-users] func_odbc insert with mssql
To: "Asterisk Users Mailing List - Non-Commercial Discussion"
	<asterisk-users at lists.digium.com>
Message-ID: <200908111219.15094.tilghman at mail.jeffandtilghman.com>
Content-Type: text/plain;  charset="iso-8859-1"

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)


That did the trick. Thank you.



More information about the asterisk-users mailing list