Page 2 of 2

Re: How to force a handler to finish it's job before proceeding with something else

Posted: Sat Apr 13, 2019 1:08 pm
by sphere
Hallo Axwald

I had a play yesterday with your script.
WIth your sqlite db it is indeed blistering fast.

I made a separate db with my data and if i change the db and column names accordingly in your test stack then it gives an error --> near ";": syntax error and the text from clipboard is then --> INSERT INTO `mydb` (`id`,`yo`,`man`) VALUES
;

if i omit the semicolon then it gies --> Your query failed! Reason: incomplete input.

2nd I tested with embedding my sqlite db in the stack, now in the IDE it sees the file (i check) and puts it perfectly in the DG.
But on Android it does see the file (i have to use specialfolder("engine") ), but does not do anything further with it. (yes all standalone dependencies are selected).

Code: Select all

put specialFolderPath("engine") & "/mydb.sqlite" into tHistDB
   if there is not a file tHistDB then
      answer "Local DB file not found" --just for test
   else
      if there is a file tHistDB then
      answer "Local DB file is here" --just for test
   put revOpenDatabase("sqlite", tHistDB, , , , ) into tLocalDbID
   put "SELECT * FROM mytable" into tSQp
   put revDataFromQuery(tab,return,tLocalDbID,tSQp) into tThis
and the rest to get it into the DG

Your stack also gave me another idea, of which i never did make use of till now and that is to add the data as a Customkey in the stack inspector and call it with the line: put the cData of this stack into theData. (never thought about it, because i always wanted to be able to update from external db)

For now this is good and also extremely fast.
And later on i can re-add the sqlite fast function when i want to add my further options to the stack. I takes minor adjustments then. So i have time to play with your written function further.

Thanks for your insights! I Appreciate it!

Re: How to force a handler to finish it's job before proceeding with something else

Posted: Mon Apr 15, 2019 7:16 pm
by AxWald
Hi,
sphere wrote:
Sat Apr 13, 2019 1:08 pm
WIth your sqlite db it is indeed blistering fast.
;-))
sphere wrote:
Sat Apr 13, 2019 1:08 pm
I made a separate db with my data and if i change the db and column names accordingly in your test stack then it gives an error --> near ";": syntax error and the text from clipboard is then --> INSERT INTO `mydb` (`id`,`yo`,`man`) VALUES
;
This looks like an empty VALUES list - makeSQLValues() must have returned an empty string (probably "the cData of this stack" are empty ...). Since this function hasn't any error handling it's assumed that the parameters are correct and the return value is checked - both tests are lacking in my stack, I admit :/
sphere wrote:
Sat Apr 13, 2019 1:08 pm
But on Android it does see the file (i have to use specialfolder("engine") ), but does not do anything further with it.
Careful with specialfolder("engine") - it's write-only on mobile. You may want to use "documents" (permanent data) or "cache" (data that are session specific) - only there you can write (i.e. INSERT into a db).
sphere wrote:
Sat Apr 13, 2019 1:08 pm
Your stack also gave me another idea, of which i never did make use of till now and that is to add the data as a Customkey
Custom properties are a great way to store data - and to react when the data changes, using setProp handlers. Right :)

Have fun!

Re: How to force a handler to finish it's job before proceeding with something else

Posted: Tue Apr 16, 2019 12:13 pm
by sphere
Thanks for your help Axwald!