I’m having some trouble with getting to the statements used by a TDAMemTable.
Both the TDADataSetCollection and TDASQLCommandCollection have TDAStatementCollection, but in both cases these are both always empty.
I’m trying to do something like this:
TDARemoteDataAdapter(aDAMemTable).Schema.DataSets[0].Statements.Count
But in this example the count is always 0 and should show 2.
Hello, I do not think that the connection alone is enough, I would really need to change the statement.
And even during the run of the application, multiple datasets can be pointing to the same table in a schema, but with a different statement. As this used to be possible in DA3.
What would be the best approach if this isn’t possible anymore?
I’d suggest to have raw tables in schema and have one statement per database type (MSSQL, MYSQL, etc).
with the DynamicSelect feature you can get only required fields.
with the DynamicWhere feature you can apply any filter
with the DASQL feature you can generate complex request from different tables.
as a result, you can get requests of any difficulty
function TDAStatement.GetDisplayName: string;
begin
if Connection <> '' then
result := Connection
else
if ConnectionType <> '' then
result := '[' + ConnectionType + ']'
else
if Name <> '' then
result := Name
else
result := '<unnamed>';
end;
we talked about this before:
in DA3 we are able to supply a statement name which executes the right statement for a table
for us this is an extremely powerfull and elegant way to have different result sets of the same table or view or schema defined sql
most of the time this can be solved with params, but there are multiple circomstances where this can’t be done elegantly using params
and it’s way cleaner to have a for example product table with a statement that returns everything possible and a statement that only fetches a small number of fiels and fills the rest of the fiels with sql constants who doesn’t need to be fetched…
or result sets based on a language …
so the question really is if the DA3 behavious is or can be supported in DA4
this is the major showstopper for us to migrate DA3 to DA4
and implementing a statement behavior using a ‘statement selection parameter’ which then returns the right sql (inside the sql definition) is far more error prone, cause you can’t directly validate each possible sql statement
i use statements also to retrieve from different db views
so i can’t use the 3 methods above
furthermore if we can’t use the statement name selection, then why is it still present?
what purpose does it serve?
I think, it all can be solved with custom GetData method what can accept additional parameter(s) like statement name or language.
you put statement name / language into session variable and when Schema asks for SQL in OnGetSQL event, you can return correct statement suitable for stored value.
by other hand, with DASQL you also can generate complicated statement from client-side so you don’t need to hardcore them into schema.
Note: ofc, some server-side DynamicWhere statements are still required by security reasons
if we need client side sql then i don’t need DA anylonger…
in case of the language, we have 3 languages over here and we need to be able to fetch on demand, so login won’t cut it
i see the power in being able to use a selection based on statements… and the drawbacks…