Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

insertId is null #18

Open
gvr2003 opened this issue Nov 10, 2013 · 3 comments
Open

insertId is null #18

gvr2003 opened this issue Nov 10, 2013 · 3 comments

Comments

@gvr2003
Copy link

gvr2003 commented Nov 10, 2013

Hi,
When I run the test application included here I am getting the insertId as null. How can I get the id of the last row that has been inserted when the INSERT query is called?

I need the last row inserted id for using in the other places as foreign key. In the below code from the test application I get insertId as undefined. Any help is greatly appreciated.

tx.executeSql(
'INSERT INTO sql_test (test_id, test_name) VALUES (?, ?);',
['1', 'Hi 1'],
function(results){console.log('Callback 2 complete')
console.log('Callback 2 complete result:'+JSON.stringify(results))
recordId = results.insertId;
console.log('Callback 2 complete result: '+recordId)

@gvr2003
Copy link
Author

gvr2003 commented Nov 13, 2013

Hi, anyone got in to this issue and knows how to resolve it?

@gvr2003
Copy link
Author

gvr2003 commented Nov 17, 2013

Is there similar library that supports non batch mode? My need is to do CRUD operations in non batch mode. Any help appreciated.

@biodiv
Copy link

biodiv commented Jan 10, 2014

this is a known bug. You will have to do a second query:

SELECT MAX(id) FROM TABLE

or

SELECT last_insert_rowid() FROM TABLE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants