View Issue Details

IDProjectCategoryView StatusLast Update
0014331FPCDatabasepublic2009-10-13 13:51
ReporterJosé Mejuto Assigned ToJoost van der Sluis  
PrioritynormalSeverityblockReproducibilityalways
Status closedResolutionfixed 
Platformi386OSWindows 
Product Version2.3.1 
Target Version2.4.0Fixed in Version2.6.0 
Summary0014331: SQLdb ApplyUpdates more than 1 record
DescriptionUsing a SQLQuery and performing 2 or more inserts or deletes causes an exception when custom SQLDelete o SQLInsert strings are present.
Steps To ReproduceAs it needs a database problem I'll post a simple subfunction.

SQLQuery1.SQLDelete.Text:='DELETE from TABLE where ID=:ID';
SQLQuery1.SQL.Text:='SELECT * from TABLE';
SQLQuery1.Open;
SQLQuery1.Delete;
SQLQuery1.Next;
SQLQuery1.Delete;
SQLQuery1.ApplyUpdates;
Additional InformationThe problem is that the if's seems to be wrong for Delete and Insert, but OK for update.

A proposed patch is attached and uses the same logic as Update.
TagsNo tags attached.
Fixed in Revision13802
FPCOldBugId
FPCTarget
Attached Files

Activities

2009-08-12 17:07

 

sqldb_insert_delete_more_than_one.patch (1,403 bytes)   
Index: sqldb.pp
===================================================================
--- sqldb.pp	(revision 13514)
+++ sqldb.pp	(working copy)
@@ -1504,17 +1504,19 @@
                qry := FUpdateQry;
                end;
     ukInsert : begin
-               if not assigned(FInsertQry) and (trim(FInsertSQL.Text)<> '') then
-                 InitialiseModifyQuery(FInsertQry,FInsertSQL.Text)
-               else
-                 InitialiseModifyQuery(FInsertQry,InsertRecQuery);
+               if not assigned(FInsertQry) then
+                 if (trim(FInsertSQL.Text)<> '') then
+                   InitialiseModifyQuery(FInsertQry,FInsertSQL.Text)
+                 else
+                   InitialiseModifyQuery(FInsertQry,InsertRecQuery);
                qry := FInsertQry;
                end;
     ukDelete : begin
-               if not assigned(FDeleteQry) and (trim(FDeleteSQL.Text)<> '') then
-                 InitialiseModifyQuery(FDeleteQry,FDeleteSQL.Text)
-               else
-                 InitialiseModifyQuery(FDeleteQry,DeleteRecQuery);
+               if not assigned(FDeleteQry) then
+                 if (trim(FDeleteSQL.Text)<> '') then
+                   InitialiseModifyQuery(FDeleteQry,FDeleteSQL.Text)
+                 else
+                   InitialiseModifyQuery(FDeleteQry,DeleteRecQuery);
                qry := FDeleteQry;
                end;
   end;

Issue History

Date Modified Username Field Change
2009-08-12 17:07 José Mejuto New Issue
2009-08-12 17:07 José Mejuto Status new => assigned
2009-08-12 17:07 José Mejuto Assigned To => Joost van der Sluis
2009-08-12 17:07 José Mejuto File Added: sqldb_insert_delete_more_than_one.patch
2009-10-04 13:54 Joost van der Sluis Fixed in Revision => 13802
2009-10-04 13:54 Joost van der Sluis Status assigned => resolved
2009-10-04 13:54 Joost van der Sluis Fixed in Version => 2.5.1
2009-10-04 13:54 Joost van der Sluis Resolution open => fixed
2009-10-04 13:54 Joost van der Sluis Target Version => 2.4.0
2009-10-13 13:51 José Mejuto Status resolved => closed