Getting data from a SQLite table

Hi All,

I am facing a strange behavior in an app here: Let me show you:

When I try to get data from a SQLIte table, I get the right result and I store it in a global variable, but after this, the variable rotaServidor only contains SQL command completed. It's very strange... or where am I wrong?

You hide all your blocks with comments

It was just to show the confirmation of results. I'll send another print right now without comments.

You have changed your blocks, and added the list fixer to the else section.

Check you blocks and code again by running them. Still the same issue ?

Yes, I did it in both cases, in order to try getting success, but unfortunately I didn't get.

I have had a look at my extension code. You should only get that output "SQL command completed" when a query returns 0 (zero) rows (e.g. when you CREATE or DELETE, or there is no data returned)

Again, look at your blocks, see where you might be calling this ?

Yes you are right. Ok, let's see: I initialize the global variable rotaServidor this way:

image

The idea is to have a table in SQLite called configuracoes, where I have all links to both dev and prod, which are filled by a table from MariaDB remote database. The table is filled correctly, as you can see the Do-It result in my first post. What I don't understand is that even returning the right link from the SQLite table, the variable does not receive this result. If I do this manually, it works...

Another point is that I made CREATEs on the SQLite database, but just in the beginning, in order to fill the tables (including the table configuracoes) and it works well, but the rotaServidor variable is not used in this context.

probably you have a running Clock in your blocks, which tries to get something from the database?
Taifun

Good point, Taifun, but I'm not using a clock in this situation...
I'm really lost...

It may help if your show the complete blocks relevant to this issue, difficult to guess when you show so little....

Ok... but there is a huge amount of blocks...

Just the relevant ones, maybe just the outer block containing your queries?

Also, why testing for development, when both if and else statements are the same?

I just did this for testing with APK... but they are different.

Here are the relevant blocks:

image

image

This looks to me like a case of trying to do everything at once (which AI2 likes to do....) so the tables and data may not be created and in place when you call the query. SQLite is quick, but maybe not that quick!

You will need a "chain of events" to overcome this:

  • open the database and test if table exists
  • if it does then create your tables and data
  • test that all tables and data, or your one specific table and data, are created and in place. You could do this by running the table exists query again....if it doesn't exist then send out the table exists query to a clock timer until it does.
  • query the data

You may instead want to move your query to the end of the criarTabelas procedure, or call a clock timer at the end to then run the query after a certain period of time.

1 Like

Ok, my friend. I'll do this tomorrow morning... my brain is exausted right now... I'll tell you my results.

you are using the variable rotaServidor only in that if then else statement...
what happens in procedure buscaConfiguracaoBancoSQLite?

Taifun

1 Like

Hi Taifun,

I'm gonna try it right now and tell you my results.

Thanks for help.

Hi @Taifun,

Did the tests here and the message is the same. I'm gonna try what @TIMAI2 said. Let's see... To me it's a weird situation... never seen this before.

image

image

What I did now was this: I am dropping the table configuracoes and the other tables just to force the test of the non-existence of tables in SQLite and to get the rotaServidor variable with the correct content.
But nothing changed. The message is still the same.