Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search for
  Advanced Search

Reconfirmation on first error when deleting multiple records


  • From: "Robins Tharakan" <tharakan(at)gmail(dot)com>
  • To: pgadmin-hackers(at)postgresql(dot)org
  • Subject: Reconfirmation on first error when deleting multiple records
  • Date: Thu, 28 Feb 2008 00:53:50 +0530
  • Message-id: <36af4bed0802271123j16acbd93t7c8344bec6eac4f0(at)mail(dot)gmail(dot)com>

Hi,

While deleting a few (400!) records from a master table (in a development database), I realised that PgAdmin just wouldn't stop displaying 400 error messages informing that each of the deletes failed (in this case because a foreign key dependency would not allow the delete to succeed).

I think a good solution to this would be that after the initial confirmation for deletion in EditGrid, the first error (during delete process) should allow the user to cancel further deletes. This can help a great deal, for e.g. in cases when the user realises his mistake as soon as the first error pops up.

Attached is a patch to do the same. Note, that the 'reconfirmation' is done only on the first error. So this takes care of another possible case when the users 'knows' that some random 20 out of his 500 deletes would fail !

Regards,
Robins Tharakan
Index: pgadmin/frm/frmEditGrid.cpp
===================================================================
--- pgadmin/frm/frmEditGrid.cpp	(revision 7105)
+++ pgadmin/frm/frmEditGrid.cpp	(working copy)
@@ -1034,8 +1034,20 @@
 
     // don't care a lot about optimizing here; doing it line by line
     // just as sqlTable::DeleteRows does
-	while (i--)
-		sqlGrid->DeleteRows(delrows.Item(i), 1);
+    int show_continue_message = 1;
+    while (i--)
+    {
+        if (!sqlGrid->DeleteRows(delrows.Item(i), 1) &&
+            i > 0 &&
+            show_continue_message == 1)
+        {
+        	wxMessageDialog msg(this, wxString::Format(_("There was an error deleting the previous record.\nAre you sure you wish to delete the remaining %d rows ?"), i), _("Delete more records ?"), wxYES_NO | wxICON_QUESTION);
+        	if (msg.ShowModal() != wxID_YES)
+            	break;
+            else
+                show_continue_message = 0;
+        }
+    }
 
 
     sqlGrid->EndBatch();


Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2008 PostgreSQL Global Development Group