Wait for DB Call
I have two functions both making select calls on the database.
I run the first call and get a value (tested by sending the value to the console).
When I use the value I got from the first in the second within the function is says the variable is undefined.
Anyone know a proper way to handle this? I don't really want to use setTimeout.
3 Answers
-
Anyone know?
-
Hi
Can you show us some code? -
Try storing the database resultset in a variable and do two seperate queries.
var query = null; var result = null; // First query query = my_db.execute('SELECT * FROM ...'); if (query.isValidRow()) { result = query.getFieldByName('my_column'); } query.close(); if (result !== null) { // Second query query = my_db.execute('SELECT * FROM ...'); // Do stuff }