Jump to content

Database access and Asynchronous


paul.coshott

Recommended Posts

Hi All,

What it the correct way to execute multiple queries one after another? The queries are being run server side, so I assume I can expect synchronous behaviour?

Can I do:

qryStaff.Close;
qryStaff.ParamByName('StaffId').AsInteger := 1;
qryStaff.Open;

qryStaffJobs.Close;
qryStaffJobs.ParamByName('JobListId').AsInteger := qryStaff.FieldByName('JobListId').AsInteger;
qryStaffJobs.Open;

The second query depends on a value from the first query. Is this ok? Or do I need to open the second query in the OnAfterOpen event of the first query?

I am using Delphi 10.2, uniGUI trial 1.7 and Firebird 3.

Thanks for any help,
Paul

Link to comment
Share on other sites

Synchronization involves the interaction between client and server,
so when you are operating on only one side there is no such problem.

The only question  in this case is if your db access methods are blocking,
and if they are they will be executed sequentially as usual.

One way to try this out is to simply test it and see what happens.

Link to comment
Share on other sites

"Blocking" refers to whether the function/method returns only after execution is completed,
or if it e.g. spawns a thread to do the job and then returns immediately without you knowing if
anything at all has been done or not.

In case of non-blocking components, you typically have to check a status event to see
how things go, or you can hook into some finishing event if that exists.

I guess most db-components are blocking, and this should be easy to determine from
their documentation.

To test things out, just get a free test server and run some tests. You can also do some
checking to see if previous changes have been applied, before each new posting, for the
most critical sections. Just to be sure.

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...