Print Thread
New property 'NotModify'
#35765 09/29/09 09:03 AM
Joined: Aug 2009
Posts: 67
S
sinys Offline OP
Member
OP Offline
Member
S
Joined: Aug 2009
Posts: 67
I ask to add a new property for TField. It must show, if the field must be updated in database when I update it in my program.

Sample query:
SQL Query
select t1.*, t1.rowid, t2.name as ABC_NAME 
from table1 t1, table2 t2 
where t1.id_abc = t2.id_abc(+)
table2 - table directory, from which the user can choose the value

My source code:
Code
procedure TForm1.OracleDataSet1AfterOpen(DataSet: TDataSet);
begin
  // My new property
  OracleDataSet1.FieldByName('ABC_NAME').NotModify := True;
end;

procedure TForm2.DBGrid1DblClick(Sender: TObject);
begin
  OracleDataSet1.Edit;
  OracleDataSet1.FieldByName('id_abc').AsInteger := OracleDataSet2.FieldByName('id_abc').AsInteger;
  OracleDataSet1.FieldByName('ABC_NAME').AsString := OracleDataSet2.FieldByName('name').AsString;
  OracleDataSet1.Post;
end;
Must send the command to update to the database only for the field 'id_abc'!

I don't REFRESH OracleDataSet1 or only one record in it (RefreshRecord) because the query selects a lot rows and in practice very complex queries and large (long run). In addition it saves bandwidth and time.
Event 'AfterOpen' is used because prior to the opening OracleDataSet1 we don't know the exact type of data
some fields (example: NUMBER or NUMBER(5)), the disorder in the databases smile. If fields can be determined in advance on some database to get an error OracleDataSet1: Type mismatch for field 'ID_ABC', expecting: Float actual: Integer.

For myself, I added a property "NotModify" (Boolean) for TOracleDataset. Please add this to the list of enhancement request.

Re: New property 'NotModify'
sinys #35770 09/29/09 12:03 PM
Joined: Aug 1999
Posts: 22,220
Member
Offline
Member
Joined: Aug 1999
Posts: 22,220
I have added this to the list of enhancement requests.


Marco Kalter
Allround Automations
Re: New property 'NotModify'
Marco Kalter #35782 09/29/09 06:16 PM
Joined: Aug 2009
Posts: 67
S
sinys Offline OP
Member
OP Offline
Member
S
Joined: Aug 2009
Posts: 67
For myself, I made:

unit OracleData;

...

// Determine if a field has been changed
function TOracleDataSet.FieldChanged(Field: TField): Boolean;
var OldValue, NewValue: Variant;
OldNull, NewNull: Boolean;
OldBlob, NewBlob: TOracleBlob;
Log: TChangeLogItem;
Rec: PRecordData;
begin
if Field.NotModify then
begin
Result := False;
Exit;
end;

...

procedure TOracleDataSet.CreateInsert(LOBList: TList; Blobs: TBLOBList);
var SQL1, SQL2, ReturningFrom, ReturningInto: string;
f: Integer;
AllNull: Boolean;
Col: TOracleFieldInfo;
begin
DMLQuery.Clear;
SQL1 := '';
SQL2 := '';
ReturningFrom := '';
ReturningInto := '';
AllNull := True;
for f := 0 to FieldInfoList.Count - 1 do
begin
Col := FieldInfoList[f];
if ((Col.InfoType = itField) and (Col.Field.FieldKind = fkData)) or
((Col.InfoType = itUnusedField) and (Col.DataType = otObject) and (not Col.IsCollection)) then
begin
if ((not Col.FieldIsNull) or Col.FieldHasDefault) and (not Col.Field.NotModify) then
begin
AllNull := False;
ColSQL(Col, True, SQL1, SQL2, ReturningFrom, ReturningInto, LOBList, Blobs);
end;


Re: New property 'NotModify'
sinys #36002 10/09/09 11:12 AM
Joined: Aug 2009
Posts: 67
S
sinys Offline OP
Member
OP Offline
Member
S
Joined: Aug 2009
Posts: 67
so, when it will already? it's very nessesary, the time is not waiting!

Re: New property 'NotModify'
sinys #36273 10/27/09 02:58 PM
Joined: Jul 2003
Posts: 112
Fino Mornasco, Como, Italy
L
Member
Offline
Member
L
Joined: Jul 2003
Posts: 112
Fino Mornasco, Como, Italy
Maybe it could use and check already existing ProviderFlags? It would use the same machanism used by datasnap.


LDS
Re: New property 'NotModify'
ldsandon #36492 11/13/09 07:16 AM
Joined: Aug 2009
Posts: 67
S
sinys Offline OP
Member
OP Offline
Member
S
Joined: Aug 2009
Posts: 67
When there will be a new version DOA with new features? smile

Re: New property 'NotModify'
sinys #36496 11/13/09 10:08 AM
Joined: Aug 1999
Posts: 22,220
Member
Offline
Member
Joined: Aug 1999
Posts: 22,220
I don't have a date yet.


Marco Kalter
Allround Automations

Moderated by  support 

Link Copied to Clipboard
Powered by UBB.threads™ PHP Forum Software 7.7.4
(Release build 20200307)
Responsive Width:

PHP: 7.1.33 Page Time: 0.034s Queries: 15 (0.010s) Memory: 2.5251 MB (Peak: 3.0394 MB) Data Comp: Off Server Time: 2024-05-16 23:30:05 UTC
Valid HTML 5 and Valid CSS