[asterisk-users] Return variables from func_odbc calls?

Tilghman Lesher tilghman at meg.abyt.es
Tue Feb 1 12:55:27 CST 2011


On Tuesday 01 February 2011 12:36:46 Jose P. Espinal wrote:
> Paul Belanger wrote:
> > On 11-01-26 02:59 PM, Tilghman Lesher wrote:
> >> On Wednesday 26 January 2011 07:01:12 Paul Belanger wrote:
> >>> [CREATECALL]
> >>> dsn=Example
> >>> writesql=INSERT INTO x (y) VALUES (z)
> >>> readsql=SELECT LAST_INSERT_ID();
> >> 
> >> That assumes you have only one call in existence at a time.  If two
> >> calls came in and executed the query at about the same time, it's
> >> possible for both reads to return the same value.
> > 
> > Yup, didn't even think of that.  My testing of ODBC was a single
> > channel.  Guess I need another method to return the last ID of the
> > record that was just inserted.
> 
> In this case, does the Asterisk connection to MySQL through odbc counts
> as a unique 'client', or does each call to a function will count as a
> 'client'?

The first.  But you need to also understand that unless you use
transactions, and specifically the transaction support in Asterisk, each
channel is not guaranteed to be using the same connection on the second
query.  Or even if they all use the same connection, the queries are not
serialized in the way that you might otherwise expect.  The transaction
support introduced in Asterisk 1.6.2 allows a connection to be reserved
exclusively to a single channel, thus ensuring that the second query on a
channel really was the very next query on the connection.

-- 
Tilghman



More information about the asterisk-users mailing list