Link to home
Start Free TrialLog in
Avatar of Member_2_7965240
Member_2_7965240

asked on

Delphi: Android software strange behaviour

Hello,

I have and Android multiplatform program written in Delphi Seattle.
I process a query like this (simplified version):
       While not MyQuery.Eof Do
        Begin
            MyProcedure(MyQuery.FieldByName('Field1').AsString );      
            MyQuery.Next;
        End;

Open in new window

This worked well, it processed every record.

Then I changed it to this:

       While not MyQuery.Eof Do
        Begin
            MyProcedure(MyQuery.FieldByName('Field1').AsString );     
            MyQuery2.Sql.Text := 'Insert into ....';
            MyQuery2.Execute;
            MyQuery.Next;
        End;

Open in new window


After this, only the first record was processed! The same code in Vcl (Windows) works perfectly.

Then I tried with a thread:

       While not MyQuery.Eof Do
        Begin
            MyProcedure(MyQuery.FieldByName('Field1').AsString );     
           MyQuery2.Sql.Text := 'Insert into ....';

           T := TTask.Run (
           procedure
            begin
              MyQuery2.Execute;
            end);

            MyQuery.Next;
        End;

Open in new window


After this, it processed again all the records but the MyQuery2 insert actually didn't happen.

Then I tried "MyMemo.Lines.Add( 'xxx'); instead of MyQuery2 and again it processed the first record only:
       While not MyQuery.Eof Do
        Begin
            MyProcedure(MyQuery.FieldByName('Field1').AsString );      
            MyMemo.Lines.Add( 'xxx');
            MyQuery.Next;
        End;

Open in new window


What is weird for me that it seems to me that sometimes Android doesn't process the commands sequentially.
What can I do? Is there a "rule book" when Android decides when not to "take care" of my next command line?

Thank you very much.
ASKER CERTIFIED SOLUTION
Avatar of Geert G
Geert G
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial