Delphi Examples: DbiGetErrorEntry

<< Click to Display Table of Contents >>

Navigation:  »No topics above this level«

Delphi Examples: DbiGetErrorEntry

Return to chapter overview

Get the error for the specified entry and return the result in a ClientError string. If a native error also exists in the entry, return it as the function result. Raise an EDatabaseError exception if an attempt is made to go beyond the end of the error stack. This example uses the following input:

 NativeError := fDbiGetErrorEntry(1, ClientStr);

 

The function is defined as:

function fDbigetErrorEntry(Entry: Word; var ClientError: String): Longint;

var

 L: Longint;

 rslt: DBIResult;

begin

 SetLength(ClientError, DBIMAXMSGLEN + 1);

 rslt := DbiGetErrorEntry(Entry, L, PChar(ClientError));

 SetLength(ClientError, StrLen(PChar(ClientError)));

 Result := L;

if (rslt = DBIERR_NONE) then

  raise EDatabaseError.Create('No errors at stack entry ' + IntToStr(Entry));

end;