Code: Select all
procedure CheckPostgreSQLError(Connection: IZConnection;
PlainDriver: IZPostgreSQLPlainDriver;
Handle: PZPostgreSQLConnect; LogCategory: TZLoggingCategory;
LogMessage: string;
ResultHandle: PZPostgreSQLResult);
var ErrorMessage: string;
//FirmOS
StatusCode:String;
begin
if Assigned(Handle) then
ErrorMessage := Trim(StrPas(PlainDriver.GetErrorMessage(Handle)))
else ErrorMessage := '';
if ErrorMessage<>'' then begin
if Assigned(ResultHandle) then begin
{ StatusCode := Trim(StrPas(PlainDriver.GetResultErrorField(ResultHandle,PG_DIAG_SEVERITY)));
StatusCode := Trim(StrPas(PlainDriver.GetResultErrorField(ResultHandle,PG_DIAG_MESSAGE_PRIMARY)));
StatusCode := Trim(StrPas(PlainDriver.GetResultErrorField(ResultHandle,PG_DIAG_MESSAGE_DETAIL)));
StatusCode := Trim(StrPas(PlainDriver.GetResultErrorField(ResultHandle,PG_DIAG_MESSAGE_HINT)));
StatusCode := Trim(StrPas(PlainDriver.GetResultErrorField(ResultHandle,PG_DIAG_STATEMENT_POSITION)));
StatusCode := Trim(StrPas(PlainDriver.GetResultErrorField(ResultHandle,PG_DIAG_INTERNAL_POSITION)));
StatusCode := Trim(StrPas(PlainDriver.GetResultErrorField(ResultHandle,PG_DIAG_INTERNAL_QUERY)));
StatusCode := Trim(StrPas(PlainDriver.GetResultErrorField(ResultHandle,PG_DIAG_CONTEXT)));
StatusCode := Trim(StrPas(PlainDriver.GetResultErrorField(ResultHandle,PG_DIAG_SOURCE_FILE)));
StatusCode := Trim(StrPas(PlainDriver.GetResultErrorField(ResultHandle,PG_DIAG_SOURCE_LINE)));
StatusCode := Trim(StrPas(PlainDriver.GetResultErrorField(ResultHandle,PG_DIAG_SOURCE_FUNCTION)));
}
StatusCode := Trim(StrPas(PlainDriver.GetResultErrorField(ResultHandle,PG_DIAG_SQLSTATE)));
end else begin
StatusCode:='';
end;
end;
if ErrorMessage <> '' then
begin
if Assigned(Connection) and Connection.GetAutoCommit then
Connection.Rollback;
DriverManager.LogError(LogCategory, PlainDriver.GetProtocol, LogMessage, 0, ErrorMessage);
if ResultHandle <> nil then PlainDriver.Clear(ResultHandle);
if PlainDriver.GetStatus(Handle) = CONNECTION_BAD then
begin
PlainDriver.Finish(Handle);
//HA 090515 removed because never used
//Handle := nil;
end;
raise EZSQLException.CreateWithStatus(StatusCode,Format(SSQLError1, [ErrorMessage]));
end;
end;