Hi Rodolfo.
You have many questions, I'll try to answer some of them as simple as I can since you didn't mention how much your understand about programming in general and about Delphi or Free Pascal and Lazarus in particular .
hi,
this is my first participation on this forum, I'm new to lazarus and pretend to write a small DB application using SQLite and SQLdb.
Did the http://wiki.freepascal.org/Lazarus_Database_Overview and the SQLdb TutorialX series (a very sweet idea but lacking the minimum to achieve a functional DB app) and still have many questions:
Are you Brazilian? If so, watch out that "pretend" is a false cognate and means "fingir" while "intend" means "pretender":
http://www.teclasap.com.br/falsos-cognatos-pretend/http://blog.influx.com.br/2014/03/14/quando-usar-to-pretend-e-to-intend/The more polite you are, the better answers you can achieve.
FPC and Lazarus are open source projects made by great effort of many people for many years, mostly on their spare time and without payment.
The same can be said about documentation, tutorials, wikis, videos, answers on forums, etc.
People do their best, but they can not supply all of everybody's needs.
So, avoid criticizing somebody's else work without providing a better free and open solution to replace it.
Your are not forbidden to ask for improvements or new features, but you have to be polite and patient, and accept a big NO most of the time as a normal response for your requests...
When you say "a functional DB app", it can be many things. I will try to help you on the first steps, but I cannot be fast nor do all the work for you. You must do your part and study and search to fill the gaps...
How to validate a record before update to the database?
There are many ways.
Your can validate each field or the whole record using RAD events, OOP or even DB triggers and constrains.
A very simple example in RAD approach would be using the event Exit of each dbware component, for example:
procedure TForm1.DBEdit1Exit(Sender: TObject);
begin
if SQLQuery1.FieldByName('FieldName1').AsInteger < 0 then
begin
TDBEdit(Sender).SetFocus;
ShowMessage('Value can not be negative.');
end;
end;
How to cancel that update, being an existing record update or an a addition, if the validation fails?
Again, there are many strategies.
You can use a second SQLQuery to search if the record already exists and no update is applied at all or you can use a rollback/commit in a try/except to manage the situation:
procedure TForm1.SQLQuery1AfterPost(DataSet: TDataSet);
begin
try
SQLQuery1.ApplyUpdates(-1);
SQLTransaction1.Commit;
ShowMessage('Record update succeeded!');
except
SQLTransaction1.Rollback;
ShowMessage('Record update failed!');
end;
end;
How to cancel a navigation to another record if there are pending updates and the validation fails?
Study the event BeforeScroll of SQLQuery.
There are also the properties CachedUpdates and UpdatesPending on Delphi, that you could also search for similar behavior on FPC.
If there are calculated fields that depend on the user input, where do I make those calculations prior to the post?
Study the events Exit of each dbware component, such as DBEdit, DBGRid, etc, and BeforePost and AfterPost of SQLQuery.
If there are calculated fields that need to be, well, 'calculated' when the record changes, where do I do that?
Study the events Exit of each dbware component, such as DBEdit, DBGRid, etc, and AfterScroll of SQLQuery.
What is the order of the events?
It depends. What events are you talking about?
For example, some events of TForm:
https://www.thoughtco.com/life-cycle-of-a-delphi-form-1058011http://www.askingbox.com/info/delphi-event-order-of-a-form-from-oncreate-to-ondestroyThank you in advance for your help.
You are welcome.
Many people, include me, will try to help you, but I strongly suggest that you do your part by studying, searching on forum, wiki, Google, etc, and, above all, be polite, patient and reasonable.