how do you get the MySQL mysql_insert_id(); from within Rev?

Josh Mellicker josh at dvcreators.net
Fri May 26 14:33:38 EDT 2006


Hmmm... I tried both of these, and got a nice round zero as a  
returned value in both cases, same as my earlier tests with  
mysql_insert_id()...

My first instinct is that I need to do the INSERT using some other  
command than revExecuteSQL? Because revExecuteSQL does not provide  
for a "Record set"?

____________________
this info from http://www.mysqlfreaks.com/statements/90.php :

LAST_INSERT_ID([expr])

The last ID that was generated is maintained in the server on a per- 
connection basis. This means the value the function returns to a  
given client is the most recent AUTO_INCREMENT value generated by  
that client. The value cannot be affected by other clients, even if  
they generate AUTO_INCREMENT values of their own. This behaviour  
ensures that you can retrieve your own ID without concern for the  
activity of other clients, and without the need for locks or  
transactions.
____________________

I have checked, and my pConnID/tDBRef is identical for both the  
INSERT and the check for the insert_id.

I will keep trying to trace it down, could be simply related to how  
I'm doing the insert or making the DB connection.

Thanks for the help!


On May 26, 2006, at 8:49 AM, Trevor DeVore wrote:
>
> Try this:
>
> function getLastInsertIDForMySQL pConnID
>     put "SELECT LAST_INSERT_ID()" into theSQL
>     return revDataFromQuery(,, pConnID, theSQL)
> end getLastInsertIDForMySQL
>

On May 26, 2006, at 5:49 AM, Ken Ray wrote:
>
> You can use revDataFromQuery right after you have done your insert  
> with
> revExecuteSQL:
>
>    get revDataFromQuery("","",tDBRef,"SELECT LAST_INSERT_ID()")
>
> You may also be able to use *another* call to revExecuteSQL to run  
> the same
> SQL statement ("SELECT LAST_INSERT_ID()"), but I've only used
> revDataFromQuery.



More information about the use-livecode mailing list