1

Re: Deleting and other batch operations

Ian Spence's recent problems have highlighted once again the need in Recorder for being able to perform batch deletes. I have needed to delete records on many occasions based on various criteria, such as:

* Delete all records in a survey
* Delete all records entered/imported on a given day
* Delete all records by a given recorder
* Delete an Event and all it contains

etc. (any other additions to this list are welcome)

These are quite destructive functions and so perhaps instead of deleting records outright, they could be snapshotted out into a separate database, so that the process is undo-able. Just an idea. Generally, though, being able to more easily delete records would make Recorder fundamentally more usable.

Following on from this, certain batch operations would also be useful, such as being able to invalidate all occurrences within a survey, event or sample.

Can anyone else think of other batch operations that would make Recorder more useful? Being able to multi-select elements and change data across all of those elements would be incredibly useful. For example, multi-select a group of samples to change their date, or location or grid ref or delete them; multi-select a group of events to change the recorder and so on.

Charles

Charles Roper
Digital Development Manager | Field Studies Council
http://www.field-studies-council.org | https://twitter.com/charlesroper | https://twitter.com/fsc_digital

2

Re: Deleting and other batch operations

I am definately in agreement with Charles about adding in the ability to batch delete records. This would give me more confidence to tackle the 10-20% of duplicates there are in the DRN database. I would add to Charles list of batch operations.... one that could move a lot of records across surveys into a new survey. For example instead of deleting the duplicate records I could simply move then all into a new survey, so that they can be exported before deletion or else left there and made invalid. The ability to identify and delete empty sample and survey events, resulting from all this deleting, would also be useful.

Graham

3

Re: Deleting and other batch operations

This feature has been needed for such a long time. Esp. as data gets corrupted due to bugs. One practice is to use a boolean field which marks a row in a table whose meaning is "delete" (TRUE) or "active" (FALSE) (FALSE is the default value on INSERT/APPEND). Thus the flag can be toggled and the action from the user can be undone. Only later when a purge command is run are the rows actually deleted. Even then, a system may move those rows off to a secondary DB for longer term undo, so to speak.

A bulk delete feature would then be able to select records by the criteria mentioned above and UPDATE the required rows, marking them TRUE. An undo is the opposite.

A row marked as "delete" could also be ignored by the front end for reporting and display, in effect the rows have gone.

Having a technique like this would mean a schema change to the required tables.

My 2p worth.

Regards,

Dave Cope,
Biodiversity Technology Officer,
Biodiversity Information Service for Powys and Brecon Beacons National Park.

4

Re: Deleting and other batch operations

Great idea Dave. I use a similar approach when deleting data manually, but instead of a delete column, I use the ENTERED_BY column, update it to 'delete' then run the delete queries. It's makes the whole process a lot more controlled.

Charles

Charles Roper
Digital Development Manager | Field Studies Council
http://www.field-studies-council.org | https://twitter.com/charlesroper | https://twitter.com/fsc_digital

5

Re: Deleting and other batch operations

Another idea: delete (or flag for deletion, as per Dave's suggestion) all records resulting from a report wizard or XML reports query.

Charles

Charles Roper
Digital Development Manager | Field Studies Council
http://www.field-studies-council.org | https://twitter.com/charlesroper | https://twitter.com/fsc_digital

6

Re: Deleting and other batch operations

Need the flag be a "delete" one. I get the impression that to carry out some of the above it would be handy to have a "multi-select" facility (which sets the flag). Following that one could perhaps carry out deletes and moves.
If the multi-select facility were also available through a filter then some further very useful operations could be performed e.g. "filter-select" all locations within a grid square (which would highlight rather than filter them) then perform some bulk operation such as moving them within the Location hierarchy.

7 (edited by davec 12-01-2007 06:56:12)

Re: Deleting and other batch operations

I get the impression that to carry out some of the above it would be handy to have a "multi-select" facility (which sets the flag). Following that one could perhaps carry out deletes and moves.

Darwyn is correct in that a flag does not have to indicate DELETE, but then if you mix in other meanings it then needs to be something other than boolean. IMHO, having multivalue flags adds complexity, and mixes, perhaps unrelated functionallity rather than the single minded suggestion for bulk delete.

But for this,

If the multi-select facility were also available through a filter then some further very useful operations could be performed e.g. "filter-select" all locations within a grid square (which would highlight rather than filter them) then perform some bulk operation such as moving them within the Location hierarchy.

I would suggest that existing techniques could be used for this without the need for flags. By selecting the records according to the filters, the front end or a stored procedure could then do additional processing such has moving them within the Locations hirarchy (UPDATE involving keys?).

It would be a good feature to have a pre-defined set of derived operations which could accept filtered input, but the data returned by the filter would need to include that referenced by the operation, so it could not be to generic.

I don't use Recorder 6 yet, so I don't know if the XML (SQL) report is flexible enough to allow the above already.

Regards,

Dave Cope,
Biodiversity Technology Officer,
Biodiversity Information Service for Powys and Brecon Beacons National Park.

8

Re: Deleting and other batch operations

I am all for this as a feature, whichever way it is done. However, my needs in particular require to be able to delete all records in a survey as I will need to illiminate records deleted from the other system which is MapMate. Otherwise I will still have those deleted records in my system, which would be wrong, and would take forever and a day.

On a similar line to all this, I have heard it said and seen it done in other databases, that records should not be deleted at all and instead merely flagged as so (I think this was mentioned earlier too). The reason for this, specifically when the system is the same (i.e. Recorder 6) is that when data is exported and exchanged, any 'deleted' records will be picked up as so and thus 'deleted' in the importing system. The records could be deleted and just the keys kept. Or they could be moved to a mirror database (or the like) so they could be accessed in the future if needed and the keys used as the flag and link to the main database.

Now, if there were any standards out there in the biological recording software world, then all systems could employ this 'standard' field to flag the deletions and data could be exchanged much more easily and thus get round the need for this deleting feature which is so desperately needed. However and after all we are a free market and everyone will never use one system.

Thanks

Brian

Brian Miller
(Conservation Officer (Buckinghamshire), BBOWT)

9

Re: Deleting and other batch operations

This is the reason why, when asked to delete a record, I mark it as invalid rather than delete it. It's really frustrating getting back records that I have previously deleted. However, this doesn't work on locations or individuals or anything other than occurrences. So I'm really keen on the delete flag idea.

Having said that, there is still a need for outright batch deletion. A purge of data with the delete flag set is an option, but then you would still have this problem of getting those deleted records back from someone else. But, if you know the data you're about to batch delete haven't been exported to someone else, it would be useful being able to delete and purge them, without purging other data that have been exported.

Charles

Charles Roper
Digital Development Manager | Field Studies Council
http://www.field-studies-council.org | https://twitter.com/charlesroper | https://twitter.com/fsc_digital

10

Re: Deleting and other batch operations

Forgot to mention regarding standards: the fact that we have a free market doesn't mean we can't have standards. The fact we have a free market is the very reason we need standards.

A little aside: the internet only really took off with the invention of the HTML standard. Once HTML came along, the proprietary online services such as AOL, Compuserv, CIX (the proprietary aspects of their platform at least) started to die. Then we had the browser wars where each browser manufaturer added their own extensions to HTML, creating a landscape excruciatingly difficult to build websites for because we had to build for the quirks of each of the different browsers. Then came the unhealthy rise to dominance of Microsoft's browser - Internet Explorer - which essentially halted progress of the web for many years until Mozilla came along with Firefox - a browser who's key feature is standards compliance.  With web developers demanding standards compliance from browser manufacturers, and by building standards compliant sites themselves, we've seen a renaissance in web applications since the crash of 2001 and the market is buyoant once more. Microsoft even relented and updated their browser (IE7) so that it has much better standards support. A web designer can now build a site that is standards compliant and be fairly confident it will run without much modification on Windows (on Firefox, IE7, Opera, etc.), Mac (on Camino, Safari, etc.) and Linux (on Firefox, Konqueror, etc.) or any other standards compliant platform.

So, open standards are fundamental in creating a free and open market. The NBN Data Model that Recorder is based on is the closest thing we have to a standard at present, which is why it's important to make use of it.

Charles

Charles Roper
Digital Development Manager | Field Studies Council
http://www.field-studies-council.org | https://twitter.com/charlesroper | https://twitter.com/fsc_digital

11

Re: Deleting and other batch operations

charlesr wrote:

Forgot to mention regarding standards: the fact that we have a free market doesn't mean we can't have standards. The fact we have a free market is the very reason we need standards.
...
So, open standards are fundamental in creating a free and open market. The NBN Data Model that Recorder is based on is the closest thing we have to a standard at present, which is why it's important to make use of it.

Agreed.

Brian

Brian Miller
(Conservation Officer (Buckinghamshire), BBOWT)

12

Re: Deleting and other batch operations

Though I agree in principle to Charles' comments above about standards, I'm still not that impressed by IE7's lack of standards compliance having just relaunched the Dorset Software website (which aims to be as standards compliant and accessible as possible). And the introduction of page zoom in IE7, which I initially thought was great, quickly turned to dismay when I realised that quite a lot of code does not work properly when zoomed and my elements were drifting all over the place! But, as rightly pointed out, properly followed standards are a great thing and would have saved a lot of work.

Enough of the moan, what I really wanted to say was that you ought to be able to write XML reports that perform batch operations. For example, someone could write an XML report that takes a survey as a parameter, then run a series of DELETE (or UPDATE etc) operations on the survey to obliterate the entire survey. At the end, the XML report code could just select 'Operation Completed' or similar.

This is a great idea because its flexible and powerful. However, there are 2 caveats. First you need to make sure you don't import and run a malicious XML report! Secondly, there are no facilities for controlling the required access level for running an XML report. However, adding a minimum access level to the attributes of a report would be a simple change, so Sarah, perhaps it could be considered for the next version if there is a consensus of opinion that this is a good approach to take.

John van Breda
Biodiverse IT

13

Re: Deleting and other batch operations

Wow, xml reports really are flexible and powerful if they can do that then!

Brian

Brian Miller
(Conservation Officer (Buckinghamshire), BBOWT)

14

Re: Deleting and other batch operations

John,

Yes, sadly, IE7 is still probably the worst of the bunch when it comes to standards compliance, but at least Microsoft have acknowledged the need for standards and responded with a product that, while still flawed, has come a long way since IE6. Unfortunately, even with the improvements in IE7, we still need to test our sites in IE6 and IE5 as so many people are still using them.

Regarding XML Reports, I too had no idea that they could do that. For some reason I had assumed UPDATES and DELETEs were disallowed. This opens up some really powerful possibilities!

In light of this, I definitely think access control on XML Report is a requirement.

Cheers,

Charles

Charles Roper
Digital Development Manager | Field Studies Council
http://www.field-studies-council.org | https://twitter.com/charlesroper | https://twitter.com/fsc_digital

15

Re: Deleting and other batch operations

Continuing with the split theme of this thread, we are finding Virtual PC is a great way to keep old versions of browsers for testing websites, as IE7, 6 & 5 don't co-exist.

And back to the main topic (again!) - here's a proposal for a possible way forward:
1) We run XML reports using a different database connection that has no privileges to change existing data.
2) We create a duplicate screen to the Open Reports screen, called "Run Batch Modification". This behaves in exactly the same way, except the XML files are loaded from a different folder to the other reports, and when you run a report it is run on an account which DOES have the ability to update the database. The Run Batch Modification screen would only be available to system managers (and perhaps full edit users). Also, there could be an additional attribute in the XML which would control whether the filter results screen is displayed, or just a success message.
3) Just like the Quick Reports menu option, there could also be Batch Modifications available on the right click menu. E.g. right click a survey, Batch Modifications>>Delete to remove all content. This would only be available to people with the required access level.

So, if we can get to the stage where there is a wide selection of reports and batch modification files ready 'out of the box' then Recorder would be a fantastically powerful product.

John van Breda
Biodiverse IT

16

Re: Deleting and other batch operations

John, that sounds great. Seems like a workable solution to me.

I've had a play with stringing batches of queries together using XML Reports in its current guise, but I'm afraid I've stumbled at the first hurdle. When doing something as simple as this:

<?xml version="1.0" ?>
<CustomReport title="Repair Last Keys" menupath="Utilities" description="Repairs the last key of each table.">
<SQL>
SELECT 'Last Key Repair has completed successfully'
<Where keytype="Default">
</Where>
</SQL>
<Columns></Columns>
</CustomReport>

When I run this using XML Reports, I get an error saying "there is an error in the SQL code. The error message is: 'Invalid object name '#REPORT_OUTPUT'". Likewise, if I try the following:

<?xml version="1.0" ?>
<CustomReport title="Repair Last Keys" menupath="Utilities" description="Repairs the last key of each table.">
<SQL>
DECLARE @TableName sysname
DECLARE cur_lastkey CURSOR FOR
SELECT TABLE_NAME FROM LAST_KEY
OPEN cur_lastkey
FETCH NEXT FROM cur_lastkey INTO @TableName
WHILE @@FETCH_STATUS = 0
BEGIN
  PRINT 'Repairing Lastkey for ' + @TableName
  EXEC dbo.spRepairLastKey @TableName
  FETCH NEXT FROM cur_lastkey INTO @TableName
END
CLOSE cur_lastkey
DEALLOCATE cur_lastkey
GO

SELECT 'Last Key Repair has completed successfully'
<Where keytype="Default">
</Where>
</SQL>
<Columns></Columns>
</CustomReport>

I get the same error. Why doesn't this work, and how exactly does one string a series of operations together?

In response to the testing on different versions of IE, take a look at this: http://tredosoft.com/Multiple_IE

Cheers,

Charles

Charles Roper
Digital Development Manager | Field Studies Council
http://www.field-studies-council.org | https://twitter.com/charlesroper | https://twitter.com/fsc_digital

17

Re: Deleting and other batch operations

Hi

Just to add to the mix of things - Stuart Ball has created a 'delete survey' addin for R6 - I wasn't aware of it until a couple of days ago.

I haven't had chance to use it yet but I think Stuart did a little bit of testing with it before he went away to the Falklands.

So whilst this may or not be the ultimate solution, at least this is a feature we could see in Recorder 6 very soon.

Regards,

Sarah

Sarah Shaw
Biodiversity Information Assistant
JNCC

Sarah Shaw
Biodiversity Information Assistant
JNCC

18

Re: Deleting and other batch operations

Charles

The report parser looks for the last query in your statement, and inserts 'INTO #Report_Output' before the FROM clause. As your last query doesn't use a FROM clause it doesn't insert the result into the output table.

You could dummy up a query which will work like the following:
SELECT TOP 1 'Report completed'
FROM Setting

Let us know how you get on.

John van Breda
Biodiverse IT

19

Re: Deleting and other batch operations

That didn't work to begin with as the output requires an alias column name. I added an alias it it worked:

SELECT TOP 1 'Report Completed' AS Result
FROM SETTING
Charles Roper
Digital Development Manager | Field Studies Council
http://www.field-studies-council.org | https://twitter.com/charlesroper | https://twitter.com/fsc_digital