Browse Source

fcl-db: interbase: SQLState must be obtained before isc_interprete is called.

git-svn-id: trunk@29165 -
lacak 10 years ago
parent
commit
6b0cd8bb0e
1 changed files with 8 additions and 10 deletions
  1. 8 10
      packages/fcl-db/src/sqldb/interbase/ibconnection.pp

+ 8 - 10
packages/fcl-db/src/sqldb/interbase/ibconnection.pp

@@ -152,27 +152,25 @@ const
 
 
 procedure TIBConnection.CheckError(ProcName : string; Status : PISC_STATUS);
 procedure TIBConnection.CheckError(ProcName : string; Status : PISC_STATUS);
 var
 var
-  Err : longint;
-  Msg : string;
+  ErrorCode : longint;
+  Msg, SQLState : string;
   Buf : array [0..1023] of char;
   Buf : array [0..1023] of char;
-  E   : EIBDatabaseError;
 
 
 begin
 begin
   if ((Status[0] = 1) and (Status[1] <> 0)) then
   if ((Status[0] = 1) and (Status[1] <> 0)) then
   begin
   begin
-    Err := Status[1];
-    Msg := '';
-    while isc_interprete(Buf, @Status) > 0 do
-      Msg := Msg + LineEnding + ' -' + StrPas(Buf);
-    E := EIBDatabaseError.CreateFmt('%s : %s', [ProcName,Msg], Self, Err, '');
+    ErrorCode := Status[1];
 {$IFDEF LinkDynamically}
 {$IFDEF LinkDynamically}
     if assigned(fb_sqlstate) then // >= Firebird 2.5
     if assigned(fb_sqlstate) then // >= Firebird 2.5
     begin
     begin
       fb_sqlstate(Buf, Status);
       fb_sqlstate(Buf, Status);
-      E.SQLState := StrPas(Buf);
+      SQLState := StrPas(Buf);
     end;
     end;
 {$ENDIF}
 {$ENDIF}
-    Raise E;
+    Msg := '';
+    while isc_interprete(Buf, @Status) > 0 do
+      Msg := Msg + LineEnding + ' -' + StrPas(Buf);
+    raise EIBDatabaseError.CreateFmt('%s : %s', [ProcName,Msg], Self, ErrorCode, SQLState);
   end;
   end;
 end;
 end;