<p dir="ltr">It is true that the luasql driver is overly basic and poorly documented . Unfortunately mysql doesn&#39;t support RETURNING clause like pgsql and oracle. You should however try SELECT LAST_INSERT_ID(); right after the insert query. I cannot guarantee it works due to the unknown nature(to me that is) of the luasql transaction handling, but it should keep a transaction open for as long as a db handler lives.<br>

</p>
<div class="gmail_quote">On May 25, 2013 7:03 AM, &quot;John M&quot; &lt;<a href="mailto:j_mj@aol.com">j_mj@aol.com</a>&gt; wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<font color="black" face="Arial, Helvetica, sans-serif"><font color="black" face="Arial, Helvetica, sans-serif">

<div> Hi <font color="black" face="Arial, Helvetica, sans-serif">Seven Du</font>,<br>
<br>
I&#39;d really like to know if this is possible too, couldn&#39;t find it documented anywhere.<br>
<br>
Instead of being cryptic, if you know the answer won&#39;t you please help by explaining what the RETURNING clause is and how to use it?<br>
<br>
Does it somehow return mysql_insert_id()?<br>
<br>
How should we use it.<br>
<br>
You help is invaluable and is contributing to the freeswitch community.<br>
<br>
-Jm<br>

</div>



<div> <br>

</div>



<div> <br>

</div>



<div style="font-size:10pt;font-family:helvetica,arial">-----Original Message-----<br>

From: Seven Du &lt;<a href="mailto:dujinfang@gmail.com" target="_blank">dujinfang@gmail.com</a>&gt;<br>

To: FreeSWITCH Users Help &lt;<a href="mailto:freeswitch-users@lists.freeswitch.org" target="_blank">freeswitch-users@lists.freeswitch.org</a>&gt;<br>

Sent: Sat, May 25, 2013 12:52 pm<br>

Subject: Re: [Freeswitch-users] dbh:query - insert id<br>

<br>






<div>

                

<div>
                    Maybe try the RETURNING clause ?
                </div>


                

<div>

<div><br>

</div>



<div>-- </div>



<div>Seven Du</div>



<div><span style="font-size:10pt"><a href="http://www.freeswitch.org.cn" target="_blank">http://www.freeswitch.org.cn</a></span></div>



<div><a href="http://about.me/dujinfang" target="_blank">http://about.me/dujinfang</a></div>



<div>

<div><a href="http://www.dujinfang.com" target="_blank">http://www.dujinfang.com</a></div>

</div>



<div><br>

</div>



<div>Sent with <a href="http://www.sparrowmailapp.com/?sig" target="_blank">Sparrow</a></div>



<div><br>

</div>

</div>


                 
                

<div style="color:#a0a0a8">On Saturday, May 25, 2013 at 8:14 AM, Lloyd Aloysius wrote:</div>


                <blockquote type="cite" style="border-left-style:solid;border-width:1px;margin-left:0px;padding-left:10px">
                    <span>

<div>

<div>

<div><font face="verdana, sans-serif">

<div>

<div><font face="verdana, sans-serif">

<div>Hello All</div>



<div><br>

</div>



<div>How to get the id value after insert a record a record using dbh:query</div>



<div><br>

</div>



<div><u>table_a - columns</u>.</div>





<div><br>

</div>



<div>id - auto increment</div>



<div>field1</div>



<div>field2</div>



<div><br>

</div>



<div><br>

</div>



<div>dbh:query(&quot;insert into table_a ( field1,field2) values (&#39;11&#39;,&#39;Test&#39;)&quot;)</div>



<div>

<br>

</div>



<div><br>

</div>



<div>After insert how to get the table_a - id value for the inserted record?</div>



<div><br>

</div>



<div>Thanks</div>



<div>Lloyd</div>

</font></div>

</div>

</font></div>


</div>



<div>

<div>_________________________________________________________________________</div>



<div>Professional FreeSWITCH Consulting Services:</div>



<div><a href="mailto:consulting@freeswitch.org" target="_blank">consulting@freeswitch.org</a></div>



<div><a href="http://www.freeswitchsolutions.com" target="_blank">http://www.freeswitchsolutions.com</a></div>



<div><br>

</div>



<div>FreeSWITCH-powered IP PBX: The CudaTel Communication Server</div>



<div><a href="http://www.cudatel.com" target="_blank">http://www.cudatel.com</a></div>



<div><br>

</div>



<div>Official FreeSWITCH Sites</div>



<div><a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a></div>



<div><a href="http://wiki.freeswitch.org" target="_blank">http://wiki.freeswitch.org</a></div>



<div><a href="http://www.cluecon.com" target="_blank">http://www.cluecon.com</a></div>



<div><br>

</div>



<div>FreeSWITCH-users mailing list</div>



<div><a href="mailto:FreeSWITCH-users@lists.freeswitch.org" target="_blank">FreeSWITCH-users@lists.freeswitch.org</a></div>



<div><a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a></div>



<div>UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a></div>



<div><a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a></div>

</div>

</div>

</span>
                 
                 
                 
                 
                </blockquote>
                 
                

<div>
                    <br>


                </div>



</div>





<div style="font-size:12px;font-family:Tahoma,Verdana,Arial,Sans-Serif;margin:0px">

<pre style="font-size:9pt"><tt>_________________________________________________________________________
Professional FreeSWITCH Consulting Services:
<a href="mailto:consulting@freeswitch.org" target="_blank">consulting@freeswitch.org</a>
<a href="http://www.freeswitchsolutions.com" target="_blank">http://www.freeswitchsolutions.com</a>

FreeSWITCH-powered IP PBX: The CudaTel Communication Server
<a href="http://www.cudatel.com" target="_blank">http://www.cudatel.com</a>

Official FreeSWITCH Sites
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a>
<a href="http://wiki.freeswitch.org" target="_blank">http://wiki.freeswitch.org</a>
<a href="http://www.cluecon.com" target="_blank">http://www.cluecon.com</a>

FreeSWITCH-users mailing list
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org" target="_blank">FreeSWITCH-users@lists.freeswitch.org</a>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a>
</tt></pre>
</div>

 



</div>

</font></font><br>_________________________________________________________________________<br>
Professional FreeSWITCH Consulting Services:<br>
<a href="mailto:consulting@freeswitch.org">consulting@freeswitch.org</a><br>
<a href="http://www.freeswitchsolutions.com" target="_blank">http://www.freeswitchsolutions.com</a><br>
<br>
FreeSWITCH-powered IP PBX: The CudaTel Communication Server<br>
<a href="http://www.cudatel.com" target="_blank">http://www.cudatel.com</a><br>
<br>
Official FreeSWITCH Sites<br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
<a href="http://wiki.freeswitch.org" target="_blank">http://wiki.freeswitch.org</a><br>
<a href="http://www.cluecon.com" target="_blank">http://www.cluecon.com</a><br>
<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
<br></blockquote></div>