Browse Source

* Changed SQLParser in a function which returns the obtained statement-type instead of setting the statementtype of the cursor directly, second part of r12512

git-svn-id: trunk@12513 -
joost 16 years ago
parent
commit
11015eb6ad
1 changed files with 10 additions and 9 deletions
  1. 10 9
      packages/fcl-db/src/sqldb/sqldb.pp

+ 10 - 9
packages/fcl-db/src/sqldb/sqldb.pp

@@ -222,7 +222,7 @@ type
     procedure OnChangeSQL(Sender : TObject);
     procedure OnChangeSQL(Sender : TObject);
     procedure OnChangeModifySQL(Sender : TObject);
     procedure OnChangeModifySQL(Sender : TObject);
     procedure Execute;
     procedure Execute;
-    Procedure SQLParser(var ASQL : string);
+    Function SQLParser(var ASQL : string) : TStatementType;
     procedure ApplyFilter;
     procedure ApplyFilter;
     Function AddFilter(SQLstr : string) : string;
     Function AddFilter(SQLstr : string) : string;
   protected
   protected
@@ -898,8 +898,9 @@ end;
 
 
 procedure TCustomSQLQuery.Prepare;
 procedure TCustomSQLQuery.Prepare;
 var
 var
-  db    : tsqlconnection;
-  sqltr : tsqltransaction;
+  db     : tsqlconnection;
+  sqltr  : tsqltransaction;
+  StmType: TStatementType;
 
 
 begin
 begin
   if not IsPrepared then
   if not IsPrepared then
@@ -919,7 +920,7 @@ begin
     if FSQLBuf = '' then
     if FSQLBuf = '' then
       DatabaseError(SErrNoStatement);
       DatabaseError(SErrNoStatement);
 
 
-    SQLParser(FSQLBuf);
+    StmType:=SQLParser(FSQLBuf);
 
 
     // There may no error occur between the allocation of the cursor and
     // There may no error occur between the allocation of the cursor and
     // the preparation of the cursor. Because internalclose (which is called in
     // the preparation of the cursor. Because internalclose (which is called in
@@ -929,7 +930,7 @@ begin
     // unpredictable results.
     // unpredictable results.
     if not assigned(fcursor) then
     if not assigned(fcursor) then
       FCursor := Db.AllocateCursorHandle;
       FCursor := Db.AllocateCursorHandle;
-
+    FCursor.FStatementType:=StmType;
     if ServerFiltered then
     if ServerFiltered then
       Db.PrepareStatement(Fcursor,sqltr,AddFilter(FSQLBuf),FParams)
       Db.PrepareStatement(Fcursor,sqltr,AddFilter(FSQLBuf),FParams)
     else
     else
@@ -1027,7 +1028,7 @@ begin
   end;
   end;
 end;
 end;
 
 
-procedure TCustomSQLQuery.SQLParser(var ASQL : string);
+function TCustomSQLQuery.SQLParser(var ASQL : string) : TStatementType;
 
 
 type TParsePart = (ppStart,ppSelect,ppWhere,ppFrom,ppOrder,ppComment,ppGroup,ppBogus);
 type TParsePart = (ppStart,ppSelect,ppWhere,ppFrom,ppOrder,ppComment,ppGroup,ppBogus);
 
 
@@ -1089,8 +1090,8 @@ begin
 
 
         case ParsePart of
         case ParsePart of
           ppStart  : begin
           ppStart  : begin
-                     FCursor.FStatementType := TSQLConnection(Database).StrToStatementType(s);
-                     if FCursor.FStatementType = stSelect then ParsePart := ppSelect
+                     Result := TSQLConnection(Database).StrToStatementType(s);
+                     if Result = stSelect then ParsePart := ppSelect
                        else break;
                        else break;
                      if not FParseSQL then break;
                      if not FParseSQL then break;
                      PStatementPart := CurrentP;
                      PStatementPart := CurrentP;
@@ -1126,7 +1127,7 @@ begin
                          ParsePart := ppBogus;
                          ParsePart := ppBogus;
                          StrLength := CurrentP-PStatementPart;
                          StrLength := CurrentP-PStatementPart;
                          end;
                          end;
-                       if FCursor.FStatementType = stSelect then
+                       if Result = stSelect then
                          begin
                          begin
                          Setlength(FFromPart,StrLength);
                          Setlength(FFromPart,StrLength);
                          Move(PStatementPart^,FFromPart[1],(StrLength));
                          Move(PStatementPart^,FFromPart[1],(StrLength));