DBManager.executeInsert() not returning a key even It added a row on mysql database

Post here your questions about Actionscript and Java server side extensions development.

Moderators: Lapo, Bax

User avatar
pogsdbest
Posts: 17
Joined: 08 Feb 2019, 10:09

DBManager.executeInsert() not returning a key even It added a row on mysql database

Postby pogsdbest » 19 Jul 2020, 19:24

im using sfs2x-core.jar and sfs2x.jar from smartfoxserver2X 2.16


I notice DBManager.executeInsert() doesn't return a key even it added the row on my mysql database.
meaning DBManager.executeInsert() return null. but when you look at your table, it successfully inserted the row.

i also notice the problem occurs when you insert the data on a table with a primary key is not set to "auto increment"

test 1 # primary key is set to auto increment
row added successfully.
DBManager.executeInsert() returns the key.

test 2 # primary key is not set to auto increment
row added successfully.
DBManager.executeInsert() returns null.

sometimes our primary key is not set to auto increment, because of database normalization.

Edit:
i realize 'auto increment' on table is really needed when using DBManager.executeInsert() to get the generated key.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: DBManager.executeInsert() not returning a key even It added a row on mysql database

Postby Lapo » 20 Jul 2020, 07:37

Hi,
if you don't use the auto-increment feature, you're deciding what key to use and therefore you don't need the database call to return it. (Because you already know its value)

Cheers
Lapo
--
gotoAndPlay()
...addicted to flash games

Return to “Server Side Extension Development”

Who is online

Users browsing this forum: No registered users and 17 guests