Hello, how can I obtain the "inserted ID" after having inserted a row with MySQL in the dialplan ? exten => s,n,MYSQL(Query resultid ${connid} INSERT INTO myTable SET C1="${ARG1}", C2="${ARG2}", timestamp="${STRFTIME(${EPOCH},,%Y-%m-%d_%H:%M:%S)}") I need to know the ID of the newly inserted row. Kind regards, Jonas. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20130820/723b052e/attachment.htm>
On 20/08/13 14:53, Jonas Kellens wrote:> Hello, > > how can I obtain the "inserted ID" after having inserted a row with > MySQL in the dialplan ? > > exten => s,n,MYSQL(Query resultid ${connid} INSERT INTO myTable SET > C1="${ARG1}", C2="${ARG2}", > timestamp="${STRFTIME(${EPOCH},,%Y-%m-%d_%H:%M:%S)}") > > I need to know the ID of the newly inserted row.You could write an AGI script in something like php or perl and get it to write to the mysql database instead. It can then set a variable which the dialplan can pick up. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20130820/9478a13d/attachment.htm>
On Tuesday 20 August 2013, Jonas Kellens wrote:> Hello, > > how can I obtain the "inserted ID" after having inserted a row with > MySQL in the dialplan ? > > exten => s,n,MYSQL(Query resultid ${connid} INSERT INTO myTable SET > C1="${ARG1}", C2="${ARG2}", > timestamp="${STRFTIME(${EPOCH},,%Y-%m-%d_%H:%M:%S)}") > > I need to know the ID of the newly inserted row. > > > > Kind regards, > Jonas.I'm not sure it's possible to do that using the simple MySQL interface provided within the dialplan. Why not write an AGI script in your favourite language (Perl, Python, PHP, Java all have AGI and MySQL bindings) to perform the INSERT query for you? You can supply values for C1 and C2 easily enough; and have your AGI script return the insert ID in a channel variable. (You could also return another channel variable indicating success or failure, if this is important.) -- AJS Answers come *after* questions.