[asterisk-users] Return variables from func_odbc calls?

Jose P. Espinal jpe at slackware-es.com
Tue Feb 1 12:36:46 CST 2011



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'?

I ask because of this:
"For LAST_INSERT_ID(), the most recently generated ID is maintained in 
the server on a per-connection basis. It is not changed by another 
client. It is not even changed if you update another AUTO_INCREMENT 
column with a nonmagic value (that is, a value that is not NULL and not 
0). Using LAST_INSERT_ID() and AUTO_INCREMENT columns simultaneously 
from multiple clients is perfectly valid. Each client will receive the 
last inserted ID for the last statement that client executed."

at: http://dev.mysql.com/doc/refman/5.0/en/getting-unique-id.html



-- 
Jose P. Espinal
http://www.eSlackware.com
IRC: Khratos @ #asterisk / -doc / -bugs




More information about the asterisk-users mailing list