Browse Source

* made TSQLCursor.create virtual
* Raise exception if no fields have the pfInUpdate flag set while updating or inserting records on applyupdates

git-svn-id: trunk@5812 -

joost 18 years ago
parent
commit
abafbc147a
2 changed files with 4 additions and 1 deletions
  1. 1 0
      fcl/db/dbconst.pp
  2. 3 1
      fcl/db/sqldb/sqldb.pp

+ 1 - 0
fcl/db/dbconst.pp

@@ -86,6 +86,7 @@ Resourcestring
   SOnUpdateError           = 'An error occured while applying the updates in a record: %s';
   SApplyRecNotSupported    = 'Applying updates is not supported by this TDataset descendent';
   SNoWhereFields           = 'There are no fields found to generate the where-clause';
+  SNoUpdateFields          = 'There are no fields found to include in the update- or insert-clause';
   SNotSupported            = 'Operation is not supported by this type of database';
   SDBCreateDropFailed      = 'Creation or dropping of database failed';
 

+ 3 - 1
fcl/db/sqldb/sqldb.pp

@@ -49,7 +49,7 @@ type
     FStatementType : TStatementType;
     FBlobStrings   : TStringList;   // list of strings in which the blob-fields are stored
   public
-    constructor Create;
+    constructor Create; virtual;
     destructor Destroy; override;
   end;
 
@@ -1191,6 +1191,7 @@ Procedure TSQLQuery.ApplyRecUpdate(UpdateKind : TUpdateKind);
         sql_set := sql_set + fields[x].FieldName + '=:' + fields[x].FieldName + ',';
       end;
 
+    if length(sql_set) = 0 then DatabaseError(sNoUpdateFields,self);
     setlength(sql_set,length(sql_set)-1);
     if length(sql_where) = 0 then DatabaseError(sNoWhereFields,self);
     setlength(sql_where,length(sql_where)-5);
@@ -1215,6 +1216,7 @@ Procedure TSQLQuery.ApplyRecUpdate(UpdateKind : TUpdateKind);
         sql_values := sql_values + ':' + fields[x].FieldName + ',';
         end;
       end;
+    if length(sql_fields) = 0 then DatabaseError(sNoUpdateFields,self);
     setlength(sql_fields,length(sql_fields)-1);
     setlength(sql_values,length(sql_values)-1);