Dynamic Select
From RemObjects Software
This is a Data Abstract Feature topic
Feel free to add your notes to this topic below.
Dynamic Select Overview
Dynamic Select is a feature introduced in Vinci. It allows you to request data from only the columns you need.
In previous versions of Data Abstract, if the client application requested data from the table then it received all fields regardless of whether they were all needed. Thus, in order to provide such selective requests, the user needed to have several instances of the same table (but with different sets of fields) in the DA schema.
Now, since Vinci, the client can dynamically specify the set of the fields needed and, as a result, only a subset of field values will be returned to the client.
The benefit of this feature is obvious - it allows you to reduce your network traffic between the database server and your middle tier and between your middle tier and client.
How it works
The TableRequestInfo structure is used for customizing the GetData process. For Vinci we decided to extend this structure and provide a new one called TableRequestInfoV5. It has a new DynamicSelectFieldNames field that can hold the requested field names as an array of string values. So, to use the Dynamic Select feature you should have code like the following:
C#
TableRequestInfoV5 ri = new TableRequestInfoV5(); ri.DynamicSelectFieldNames = new string[] {"employeeID", "firstName", "title", "birthDate", "hireDate"}; remoteDataAdapter.Fill(newDataset, "Employees", ri);
Delphi
var lStream: TMemoryStream; lTableRequestInfoArray: TableRequestInfoArray; lTableNameArray: StringArray; lTableRequestInfo: TableRequestInfoV5; begin lTableNameArray := StringArray.Create; lTableRequestInfoArray := TableRequestInfoArray.Create; try lTableNameArray.Add('Employees'); lTableRequestInfo := TableRequestInfoV5.Create(nil); lTableRequestInfoArray.Add(lTableRequestInfo); with lTableRequestInfo do begin IncludeSchema := true; MaxRecords := -1; DynamicSelectFieldNames.Add('EmployeeID'); DynamicSelectFieldNames.Add('FirstName'); DynamicSelectFieldNames.Add('Title'); DynamicSelectFieldNames.Add('BirthDate'); DynamicSelectFieldNames.Add('HireDate'); end; lStream := fService.GetData(lTableNameArray, lTableRequestInfoArray); if lStream <> nil then try DataStreamer.ReadDataset(lStream, tbl_Employees, True); finally lStream.Free; end; finally lTableRequestInfoArray.Free; lTableNameArray.Free; end;
When the server processes such a request then two outcomes are possible depending on the table's statement type.
- If the table is based on an AutoSQL statement then info regarding the requested fields will be used during the SQL generation and the DA server will only request the required fields from the database. It will decrease the network traffic between the database server, DA server and client.
- If the table is based on a standard SQL statement then all data will be requested from the database (according to the table's SQL statement) but the DA server outputs to result stream to the client only those fields actually requested by the client. It will decrease network traffic only between the DA server and client.
Security
Note that in order to use 'Dynamic Select you need to activate it:
- on the client, set Remote Data Adapter's new boolean DynamicSelect property to True. By default it is set to False (i.e. Dynamic Requests are not allowed). Once set to True, the list of the fields to select will be created every time that you request data, even if you didn't specify any fields in TableRequestInfoV5.
- on the server, set the Service's AllowDynamicSelect property to True (False by default).
See Also
- DynamicSelect property
- Dynamic Where
- Reduced Delta Mode
Product: RemObjects Data Abstract
Current version: Data Abstract 'Vinci' (5.0)
Lists — Glossary — Features — How To — Drivers — Components — Tools — Samples — Articles — Architecture — Issues
