Hi
I am developing a SQL database that will sync with handhelds used to collect data in the field. This will be a two way sync, as I want all handhelds to hold previous data, so the handhelds can run statistical analysis on new data, before excepting. This is ok, but I want to limit the data the handhelds recieve.
The handhelds will sync to a view of a table with the structure:
SELECT OID, sBHVisitID, sSiteVisitID, sSamplePointID, sSiteName, dDateTime, fDTW, fDTB, bSampled, sSampleMethod, fPurgeVol, fpH, fTemp, lEC, lPulseCount, fFlow, sComments, oScribbleNote, sGPSLat, sGPSLong, sGPSAlt, bProcessed, bDeactivated, bArchived, bDeleted, fDO, sPersonnel, sPersonnelUpdated, sDeviceID, sDeviceIDUpdated, dUpdated, TIMESTAMP
FROM dbo.VBHVisit
WHERE (bDeactivated = 0) AND (bArchived = 0) AND (bDeleted = 0)
What I would like to do is add a way that when a new INSERT statement is executed on the underlying table, a procedure executes to count the number of records for each sSamplePointID now visible in this view (preferably just for the sSamplePointIds affected as each record is inserted), sorted by dDateTime, and where there are more than 5 records for each sSamplePointID, update their bArchived to 'true' for all but the 5 most recent records. This will cause the now archived records to drop out of the view.
Thanks for reading, your help is very appreciated.
John
I am developing a SQL database that will sync with handhelds used to collect data in the field. This will be a two way sync, as I want all handhelds to hold previous data, so the handhelds can run statistical analysis on new data, before excepting. This is ok, but I want to limit the data the handhelds recieve.
The handhelds will sync to a view of a table with the structure:
SELECT OID, sBHVisitID, sSiteVisitID, sSamplePointID, sSiteName, dDateTime, fDTW, fDTB, bSampled, sSampleMethod, fPurgeVol, fpH, fTemp, lEC, lPulseCount, fFlow, sComments, oScribbleNote, sGPSLat, sGPSLong, sGPSAlt, bProcessed, bDeactivated, bArchived, bDeleted, fDO, sPersonnel, sPersonnelUpdated, sDeviceID, sDeviceIDUpdated, dUpdated, TIMESTAMP
FROM dbo.VBHVisit
WHERE (bDeactivated = 0) AND (bArchived = 0) AND (bDeleted = 0)
What I would like to do is add a way that when a new INSERT statement is executed on the underlying table, a procedure executes to count the number of records for each sSamplePointID now visible in this view (preferably just for the sSamplePointIds affected as each record is inserted), sorted by dDateTime, and where there are more than 5 records for each sSamplePointID, update their bArchived to 'true' for all but the 5 most recent records. This will cause the now archived records to drop out of the view.
Thanks for reading, your help is very appreciated.
John