Browse Source

* Check for an empty statement before the cursor is allocated so that the right error message is shown. (+test which was committed partly in r12510 already)

git-svn-id: trunk@12511 -
joost 16 years ago
parent
commit
8922c3e310
2 changed files with 5 additions and 5 deletions
  1. 3 4
      packages/fcl-db/src/sqldb/sqldb.pp
  2. 2 1
      packages/fcl-db/tests/testfieldtypes.pas

+ 3 - 4
packages/fcl-db/src/sqldb/sqldb.pp

@@ -914,15 +914,14 @@ begin
     if not Db.Connected then db.Open;
     if not Db.Connected then db.Open;
     if not sqltr.Active then sqltr.StartTransaction;
     if not sqltr.Active then sqltr.StartTransaction;
 
 
-//    if assigned(fcursor) then FreeAndNil(fcursor);
-    if not assigned(fcursor) then
-      FCursor := Db.AllocateCursorHandle;
-
     FSQLBuf := TrimRight(FSQL.Text);
     FSQLBuf := TrimRight(FSQL.Text);
 
 
     if FSQLBuf = '' then
     if FSQLBuf = '' then
       DatabaseError(SErrNoStatement);
       DatabaseError(SErrNoStatement);
 
 
+    if not assigned(fcursor) then
+      FCursor := Db.AllocateCursorHandle;
+
     SQLParser(FSQLBuf);
     SQLParser(FSQLBuf);
 
 
     if ServerFiltered then
     if ServerFiltered then

+ 2 - 1
packages/fcl-db/tests/testfieldtypes.pas

@@ -1526,7 +1526,8 @@ begin
       Open;
       Open;
     except
     except
       on E:EDatabaseError do
       on E:EDatabaseError do
-        if pos(SErrNoStatement,E.Message) > -1 then PassException := True;
+        if Pos(SErrNoStatement,E.Message) > 0 then
+          PassException := True;
     end;
     end;
     AssertTrue(PassException);
     AssertTrue(PassException);
     end;
     end;