A atiaust Active Member Licensed User Longtime User Sep 28, 2016 #1 Hi All, I am trying to get the LAST_INSERT_ID after an INSERT into a Mysql table. Code: Copy dim lastID as INT gSQL.ExecNonQuery2("INSERT INTO table VALUES (?,?,?,?,?,?)",Array As Object(Null,u(1),u(2),u(3),u(4),Null)) lastID = gSQL.ExecQuery("LAST_INSERT_ID()") Log("Last ID +"&lastID) I know this code is incorrect but I can't find the correct way of using it in B4j. Thanks Any help appreciated. Last edited: Sep 29, 2016
Hi All, I am trying to get the LAST_INSERT_ID after an INSERT into a Mysql table. Code: Copy dim lastID as INT gSQL.ExecNonQuery2("INSERT INTO table VALUES (?,?,?,?,?,?)",Array As Object(Null,u(1),u(2),u(3),u(4),Null)) lastID = gSQL.ExecQuery("LAST_INSERT_ID()") Log("Last ID +"&lastID) I know this code is incorrect but I can't find the correct way of using it in B4j. Thanks Any help appreciated.
fixit30 Active Member Licensed User Longtime User Sep 28, 2016 #2 How about Code: Copy dim lastID as INT gSQL.ExecNonQuery2("INSERT INTO table VALUES (?,?,?,?,?,?)",Array As Object(Null,u(1),u(2),u(3),u(4),Null)) lastID = gSQL.ExecQuerySingleResult("LAST_INSERT_ID()") Log("Last ID +"&lastID) Upvote 0
How about Code: Copy dim lastID as INT gSQL.ExecNonQuery2("INSERT INTO table VALUES (?,?,?,?,?,?)",Array As Object(Null,u(1),u(2),u(3),u(4),Null)) lastID = gSQL.ExecQuerySingleResult("LAST_INSERT_ID()") Log("Last ID +"&lastID)
A atiaust Active Member Licensed User Longtime User Sep 29, 2016 #3 Thanks fixit30 Close but didn't work either. After a little more research, the correct code is: Code: Copy lastID = gSQL.ExecQuerySingleResult("SELECT LAST_INSERT_ID()") Upvote 0
Thanks fixit30 Close but didn't work either. After a little more research, the correct code is: Code: Copy lastID = gSQL.ExecQuerySingleResult("SELECT LAST_INSERT_ID()")