Dynamic SQL
Purpose
This demo shows how to retrieve schema and/or data via SQL generated at
runtime.
When you compile and run the server, you will see it contains a memo displaying
"SQL details generated for Update will be displayed here".
The
demo does not actually attempt to update server data but merely display
the fields
that would be updated by processing the delta. See the TDynSQLService.UpdateData
code in DynSQLService_Impl to see how the delta is being processed.
Having next compiled and run the client, the first thing to try
is clicking
on the Retrieve Schema and Data button and you should then see the
Customers
data displayed in the grid. Changing the text in the memo, e.g. to
Select
* from "Order Details" and clicking the button again results
in the
display of a different dataset with a totally different schema. Any of
the datasets
in the database (Northwind, by default) may be accessed in this manner.
Other points of interest:
-
As their names suggest, the Retrieve Schema and Retrieve Data
buttons
achieve the same as the Retrieve Schema and Data button. You might
want
to use them separately if the data has the same layout as the schema already
retrieved.
For example, having retrieved all the records (Max Records = -1),
you can
change the number of records required and select Retrieve Data because
the schema is correct. If you change the actual SQL though, you will need
to reload
the schema.
-
Save and Load buttons. Save stores the schema and
data in
Data.dat in the sample folder. If you only want to save the schema,
set
Max Records = 0 and retrieve schema and data (otherwise Save cannot work
because
the dataset is not open). Load restores the schema and any records
saved
no matter what data is currently open. Thus you can think of retrieve and
load
as similar operations but with remote and local data respectively.
-
The Update button simulates updating the dataset. You can see the
result
in the memo contained in the server form.