Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 7 of 7 total
Thread Strange kind of error report (not EDBISAMEngineError?)
Sun, Jan 22 2006 10:58 AMPermanent Link

Joze
Hi,

I am new at Dbisam (still learning) so please be kind with me Wink

I have few required fields in my table. When I delete such field's value an try
to post changes an error is reported. This was expected.

I am using code from manuals:

procedure TForm1.DBISAMTable1PostError(DataSet: TDataSet; E: EDatabaseError; var
Action: TDataAction);
begin
 Action := daAbort;
 if (E is EDBISAMEngineError) then
   begin
     if (EDBISAMEngineError(E).ErrorCode = DBISAM_KEYVIOL) then
       MessageDlg('A record with the same key value(s) already exists, ' +
                  'please change the record to make the value(s) unique ' +
                  'and re-post the record', mtError, [mbOK], 0)

     else if (EDBISAMEngineError(E).ErrorCode = DBISAM_REQDERR) then
       MessageDlg('The ' + EDBISAMEngineError(E).ErrorFieldName + ' field is
required, ' +
                  'please change the record to provide a value for this field '
+   'and re-post the record', mtError, [mbOK], 0)

     else if (EDBISAMEngineError(E).ErrorCode = DBISAM_MINVALERR) or
             (EDBISAMEngineError(E).ErrorCode = DBISAM_MAXVALERR) then
       MessageDlg('The value provided for the ' +
EDBISAMEngineError(E).ErrorFieldName + ' field is invalid, ' +
                  'please change the record to provide a proper value for this
field ' +    'and re-post the record', mtError, [mbOK], 0)

     else if (EDBISAMEngineError(E).ErrorCode = DBISAM_LOCKED) then
       begin
         if MessageDlg('The table you are trying to add is currently locked, '
+   'do you want to try to post this record again?',
                       mtWarning, [mbYes, mbNo], 0) = mrYes then
           Action := daRetry;
       end
     else
       MessageDlg(E.Message, mtError, [mbOK], 0);
   end
 else
   MessageDlg(E.Message, mtError, [mbOK], 0);
end;

I was expecting error would be reported as DBISAM_REQDERR but it isn't.
Error is reported in last line of PostError procedure - so the error isn't
an EDBISAMEngineError !? I was expecting it should be an EDBISAMEngineError.

 if (E is EDBISAMEngineError) then
    ....
 else
   Error is reported here !!!

How is this possible?

Can someone explain this please.

Dbisam 4.22 build 1
Delphi 7
Win XP

TIA for any explanation.

Regards,

Joze

P.S.
I have a small demo if someone want to see it
Sun, Jan 22 2006 11:16 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Joze


As a guess the error is being raised BEFORE DBISAM does its checks. What you have to remember is that DBISAM is built on top of Delphi and uses much of it (eg TFields) so for example if you define a persistent field using the fields editor in the IDE and set required there rather than in the table definition Delphi will object to the fact that its null not DBISAM.

Roy Lambert
Sun, Jan 22 2006 11:22 AMPermanent Link

Joze
Additional notes:

for other type od errors like:

  if (EDBISAMEngineError(E).ErrorCode          = DBISAM_KEYVIOL)
  else if (EDBISAMEngineError(E).ErrorCode = DBISAM_MINVALERR) or
              (EDBISAMEngineError(E).ErrorCode = DBISAM_MAXVALERR) then

it works OK.

Regards,

Joze
Sun, Jan 22 2006 11:40 AMPermanent Link

Joze
Hi Roy,

Thanks for your help.

Yes, I defined fields using the fields editor in the IDE.
If I set required property to false in IDE Dbisam is reporting DBISAM_REQDERR
error.

If I delete all defined fields in IDE, Delphi (and not Dbisam) is reporting this
error again.

My test shows:

- without defining fields in IDE error is reported by Delphi.
- if I define fields in IDE and I leave required property to true, error is
reported by Delphi
- if I define fields in IDE and I set required property to false, error is
reported by Dbisam

So my question is: should I allways clear required propety in IDE to prevent
error report from Delphi (and leave it to Dbisam)?

Regards,

Joze


On Sun, 22 Jan 2006 16:16:43 +0000, Roy Lambert <roy.lambert@skynet.co.uk>
wrote:

>Joze
>
>
>As a guess the error is being raised BEFORE DBISAM does its checks. What you have to remember is that DBISAM is built on top of Delphi and uses much of it (eg TFields) so for example if you define a persistent field using the fields editor in the IDE and set required there rather than in the table definition Delphi will object to the fact that its null not DBISAM.
>
>Roy Lambert
Sun, Jan 22 2006 12:55 PMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Joze


My approach would be either to enforce in code yourself (probably in the BeforePost or fields OnValidate events) or define the constraints at the table level when creating the table (or alter using DBSys). Using either of those approaches you don't have to worry about inconsistencies in how Delphi / whatever database works.

Roy Lambert
Sun, Jan 22 2006 3:08 PMPermanent Link

Joze
Roy,

I create my table with DbSys and option required is set (only) there.

If I don't define any fields in IDE required error is still reported
by Delphi and not by Dbisam.

So the only way I've found (with your tip) to prevent this is
to define fields in IDE using fields editor and then manually
set all fields required property to false (using IDE fields editor).
Only this way required error is than reported by Dbisam and not by Delphi.

Is this the only way or am I doing something wrong?

Regards,

Joze
Mon, Jan 23 2006 5:26 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Joze,

<< So my question is: should I allways clear required propety in IDE to
prevent error report from Delphi (and leave it to Dbisam)? >>

Yes, that is the correct way to force the required checks to be handled by
DBISAM.

--
Tim Young
Elevate Software
www.elevatesoft.com

Image