Auto-updateable results?
Auto-updateable results?
Hi,
It seems that all my resultsets are read-only by default. According to the ODAC help, you need to fill in "SQLInsert" and "SQLDelete" (etc) properties.
However, with my particular application, users will enter ad-hoc statements and expect them to be editable.
Is there any way around this?
--
Martijn Tonies
Upscene Productions
It seems that all my resultsets are read-only by default. According to the ODAC help, you need to fill in "SQLInsert" and "SQLDelete" (etc) properties.
However, with my particular application, users will enter ad-hoc statements and expect them to be editable.
Is there any way around this?
--
Martijn Tonies
Upscene Productions
Try to add RowId field to your SQL statement, for ex:
Code: Select all
Select E.RowId, E.* from Emp E
ODAC doesn't have public functionality that you need but you can use
following
SQL statement to get key fields of certain table:
where parameter :Owner fits to current schema name (e.g.: SCOTT)
and parameter :Name fits to updatable table name (e.g.: EMP)
Note that all parameters must be in upper case.
following
SQL statement to get key fields of certain table:
Code: Select all
SELECT
Column_Name Col, Con.Constraint_Name Con
FROM
All_Constraints Con, All_Cons_Columns Col
WHERE
Con.Owner = :Owner and
Con.Owner = Col.Owner and
Con.Table_Name = :Name and
Con.Constraint_Type in ('P', 'U') and
Con.Owner = Col.Owner and
Con.Constraint_Name = Col.Constraint_Name
ORDER BY
Con.Constraint_Name,Col.Position
and parameter :Name fits to updatable table name (e.g.: EMP)
Note that all parameters must be in upper case.
Alex,
I know how to get the PK fields and all... But that's not what I'm asking...
I'm asking for a resultset that's editable without having me to jump through hoops, but let the componentset figure it out. If it cannot figure it out, a read-only resultset is fine.
But currently, the components don't seem to do anything to create an auto-updateable resultset, which is rather, well, annoying.
--
Martijn Tonies
Upscene Productions
I know how to get the PK fields and all... But that's not what I'm asking...
I'm asking for a resultset that's editable without having me to jump through hoops, but let the componentset figure it out. If it cannot figure it out, a read-only resultset is fine.
But currently, the components don't seem to do anything to create an auto-updateable resultset, which is rather, well, annoying.
--
Martijn Tonies
Upscene Productions
TSmartQuery does not make auto-updateable resultset for user defined SQL statements. It is impossible to make for each SQL statement. You must choose key fields and assign to TSmartQuery.KeyFields property to make resultset updateable. There is no good algorithm for defining key fields. So users must define them themselves and assign TSmartQuery.KeyFields property.
Paul,
I must say this surprises me a bit...
I use many different data-access componentsets and they all try to make a result-set editable.
If it's a it's fairly easy. The componentset can figure out any PK or Unique constraint fields and use those. If not, ROWID could get added internally.
If it's a more complex select (join etc), it cannot be done. Which is fine. But at least the "easy" stuff, IMO, is a task for the data-access layer.
--
Martijn Tonies
Upscene Productions
I must say this surprises me a bit...
I use many different data-access componentsets and they all try to make a result-set editable.
If it's a
Code: Select all
select ... from single_table
If it's a more complex select (join etc), it cannot be done. Which is fine. But at least the "easy" stuff, IMO, is a task for the data-access layer.
--
Martijn Tonies
Upscene Productions
Well, could you make the behaviour optional, turned OFF by default then?
I know it would save me time, and probably others as well.
If I remember correctly, this is what the "normal" dataset (TSQLDataset) in Delphi do as well.
btw, the Allround Automation components act the same -> they do not automatically create an editable resultset, but the resultset does become editable if you add "ROWNUM" to the list of selected fields.
--
Martijn Tonies
Upscene Productions

I know it would save me time, and probably others as well.
If I remember correctly, this is what the "normal" dataset (TSQLDataset) in Delphi do as well.
btw, the Allround Automation components act the same -> they do not automatically create an editable resultset, but the resultset does become editable if you add "ROWNUM" to the list of selected fields.
--
Martijn Tonies
Upscene Productions