Column Date and Validating issue

The offical for ZeosLib 7.3 Report problems, ask for help, post proposals for the new version of Zeoslib 7.3/v8
Quick Info:
-We made two new drivers: odbc(raw and unicode version) and oledb
-GUID domain/field-defined support for FB
-extended error infos of Firebird
-performance ups are still in queue
In future some more feature will arrive, so stay tuned and don't hassitate to help
Post Reply
louis
Expert Boarder
Expert Boarder
Posts: 107
Joined: 02.01.2009, 19:41

Column Date and Validating issue

Post by louis »

Hello,
I try to upgrade my application from Zeos 7.2.0b to 8.0.0-r7490.

This code present in the OnValidate event of the column DATA_REGISTRAZIONE:

Code: Select all

procedure TForm11.ztbDocTestaDATA_REGISTRAZIONEValidate(Sender: TField);
begin
  zquery1DATA_DOCUMENTO.Value := ZQuery1DATA_REGISTRAZIONE.Value;
end;
I obtain this result:
'0000-00-00'
in the column zquery1DATA_DOCUMENTO.Value.

If I change .Value with .AsDateTime the result in zquery1DATA_DOCUMENTO is '30/12/1899'!

This code present in the OnValidate event of the column DATA_DOCUMENTO:

Code: Select all

procedure TForm11.ztbDocTestaDATA_DOCUMENTOValidate(Sender: TField);
begin
  if (ZQuery1DATA_DOCUMENTO.AsDateTime > ZQuery1DATA_REGISTRAZIONE.AsDateTime) then
    raise Exception.Create('The registration date is more recent than the date of the document!');
end;
seem to work but even if DATA_DOCUMENTO is larger then DATA_REGISTRAZIONE don't raise error!

why those results? What i'm wrong?

Thanks
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1918
Joined: 17.01.2011, 14:17

Re: Column Date and Validating issue

Post by marsupilami »

Hello Louis,

I think, it really depends on the value of ZQuery1DATA_REGISTRAZIONE.Value when that happens. What is the value of ZQuery1DATA_REGISTRAZIONE in the database? Do you use firebird or interbase as the protocol?

Best regards,

Jan
louis
Expert Boarder
Expert Boarder
Posts: 107
Joined: 02.01.2009, 19:41

Re: Column Date and Validating issue

Post by louis »

marsupilami wrote: 27.04.2021, 21:07 I think, it really depends on the value of ZQuery1DATA_REGISTRAZIONE.Value when that happens. What is the value of ZQuery1DATA_REGISTRAZIONE in the database?
The value is entered via the keyboard, example: "27/04/2021".
Do you use firebird or interbase as the protocol?
Firebird.

Thanks.
louis
Expert Boarder
Expert Boarder
Posts: 107
Joined: 02.01.2009, 19:41

Re: Column Date and Validating issue

Post by louis »

Hello,
now I notice that in an OnValidate event, the parameter Sender contains the new value but the Field still has the old value.

Changing the code from:

Code: Select all

procedure TForm11.ztbDocTestaDATA_DOCUMENTOValidate(Sender: TField);
begin
  if (ZQuery1DATA_DOCUMENTO.AsDateTime > ZQuery1DATA_REGISTRAZIONE.AsDateTime) then
    raise Exception.Create('The registration date is more recent than the date of the document!');
end;
with

Code: Select all

procedure TForm11.ztbDocTestaDATA_DOCUMENTOValidate(Sender: TField);
begin
  if (Sender.Value > ZQuery1DATA_REGISTRAZIONE.AsDateTime) then
    raise Exception.Create('The registration date is more recent than the date of the document!');
end;
then works, if the new value entered in the DBControl that contain column ZQuery1DATA_DOCUMENTO is newer of ZQuery1DATA_REGISTRAZIONE.Value raise the exception.

Normally in delphi the column already has the new value inside the OnValidate event while with Zeos it seems that, on the contrary, it doesn't have it yet.

I'm confused :(
louis
Expert Boarder
Expert Boarder
Posts: 107
Joined: 02.01.2009, 19:41

Re: Column Date and Validating issue

Post by louis »

I try disabling ZFields (DisableZFields in ZQuery) and generate all new normal persistent fields. I wonder because now the value entered in a DBControl that contain ZQuery1DATA_REGISTRAZIONE is BLANK after OnValidate event even if the value was assignet at Column ZQuery1DATA_DOCUMENTO!

there is a bug?

I'm more confused
louis
Expert Boarder
Expert Boarder
Posts: 107
Joined: 02.01.2009, 19:41

Re: Column Date and Validating issue

Post by louis »

Hello,
I installed new release 7517 but not work, OnValidate is unusable :(

Thanks
User avatar
EgonHugeist
Zeos Project Manager
Zeos Project Manager
Posts: 1936
Joined: 31.03.2011, 22:38

Re: Column Date and Validating issue

Post by EgonHugeist »

Hello Luis,

welcome on V8. Be patient we'll get you in. According your proplem can you create a min example and open a ticket on https://sourceforge.net/p/zeoslib/tickets/ A bit more code would be nice to resolve the problem.
Best regards, Michael

You want to help? http://zeoslib.sourceforge.net/viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/

Image
louis
Expert Boarder
Expert Boarder
Posts: 107
Joined: 02.01.2009, 19:41

Re: Column Date and Validating issue

Post by louis »

louis
Expert Boarder
Expert Boarder
Posts: 107
Joined: 02.01.2009, 19:41

Re: Column Date and Validating issue

Post by louis »

Hello,
may be i find the bug?

in a procedure:

Code: Select all

procedure TZAbstractRODataset.SetFieldData(Field: TField; Buffer: {$IFDEF WITH_TVALUEBUFFER}TValueBuffer{$ELSE}Pointer{$ENDIF};
  NativeFormat: Boolean);
begin
  if Field.DataType in [ftWideString, ftBCD, ftDate, ftTime, ftDateTime] then begin
    NativeFormat := True;
    if (Field.DataType <> ftWideString) then
      FNativeFormatOverloadCalled[Field.DataType] := True;
  end;

  {$IFNDEF VIRTUALSETFIELDDATA}
  inherited SetFieldData(Field, Buffer, NativeFormat);
  {$ELSE}
  SetFieldData(Field, Buffer);
  {$ENDIF}
end;

This assignation
FNativeFormatOverloadCalled[Field.DataType] := True;
not wotks because
FNativeFormatOverloadCalled[Field.DataType] is ever False!

See the Watch list on attached file to see that the debbugger is beyond the line and even if the FieldDataType is ftDate and for this the line FNativeFormatOverloadCalled[Field.DataType] := True; has executed the value of FNativeFormatOverloadCalled[Field.DataType] is not changed and it is still False.

I don't understand why
You do not have the required permissions to view the files attached to this post.
Post Reply