Best Practices related to client/server queries
Posted on 2004-10-28
I have been out of touch with Delphi development for a while, and need some pointers using certain delphi controls with data from a database connection.
I am using Delphi 7 with Oracle 806 as backend, and need to develop a client / server application using BDE. I am basically looking for the best way (fastest / easiest) to use certain delphi controls with TDatabase data.
As the application develops, I will probably ask more questions, but at the moment I only have one or two.
I thought to split the points between comments.
1. I have a form which needs to display master/detail data. The form will be split horisontally with one master record details displayed in the top half. The master detail record data will be extracted and populated on creation of the form. The detail records for the master record will then be displayed one by one in the bottom half and can each be viewed by using previous / next buttons.
The question now is whether you open a query, keep it open and use recordset.next / previous when a button is clicked, or load all the detail records into an array or pointer and close the query, or maybe some better way?
This probably also depends on whether it is a big resultset or not. In this case, it would be under 100 detail records for each master record, but each detail record has around 30 columns/fields, that need to be written to edit/comboboxes each time previous/next is clicked.
2. On a general note. Is it better practise to keep you queries inside Tquery componenst on a datamodule, or write each query in the code ie. Query1.Close; Query.SQL.Clear; Query1.SQL.Add('select * from tab'); Query.Open.?