You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Makes sure no quadrats (20 x 20 meter subsection of plot) are repeated
publicfunctionscreenDuplQuadratInfo ()
{
$q1 = "SELECT QuadratName,PersonnelID,RoleID,DateWorked,Form,COUNT(QuadratName) AS cnt FROM TempPersonnelInfo WHERE Errors<>'NONE' GROUP BY QuadratName,PersonnelID,RoleID,DateWorked,Form HAVING cnt > 1";
$query1 = $this->screeningdb->query($q1);
if ($query1->num_rows() > 0)
{
foreach($query1->result() as$row)
{
$q2 = 'UPDATE TempPersonnelInfo SET Errors = CONCAT(TRIM(Errors),";Duplicate Record") WHERE QuadratName = "'.$row->QuadratName.'" AND PersonnelID='.$row->PersonnelID.' AND RoleID='.$row->RoleID.' AND DateWorked="'.$row->DateWorked.'" and Form="'.$row->Form.'" and Errors <> "" AND Errors IS NOT NULL';
$q3 = 'UPDATE TempPersonnelInfo SET Errors = "Duplicate Record" WHERE QuadratName = "'.$row->QuadratName.'" AND PersonnelID='.$row->PersonnelID.' AND RoleID='.$row->RoleID.' AND DateWorked="'.$row->DateWorked.'" and Form="'.$row->Form.'" AND (Errors = "" OR ISNULL(Errors))';
$runQ2 = $this->screeningdb->query($q2);
$runQ3 = $this->screeningdb->query($q3);
}
}
}
Here is an updated procedure to run this and mark its errors in the CMVErrors table! Function's been reviewed with GPT so it should work as intended, but full testing is still pending:
create
definer = azureroot@`%`procedure ValidateFindDuplicatedQuadratsByName()
BEGININSERTINTOforestgeo_bci.cmverrors (CoreMeasurementID, ValidationErrorID)
SELECTcm.CoreMeasurementID,
11AS ValidationErrorID
FROMforestgeo_bci.quadrats q
JOINforestgeo_bci.coremeasurements cm ONq.QuadratID=cm.QuadratIDWHERE
(q.PlotID, q.QuadratName) IN (
SELECT
PlotID,
QuadratName
FROMforestgeo_bci.quadratsGROUP BY
PlotID, QuadratName
HAVINGCOUNT(*) >1
)
GROUP BYcm.CoreMeasurementID;
END;
See "instructions for writing a validation function". Below are notes from the spec, the original validation function (in the PHP language), and the SQL table structure.
The text was updated successfully, but these errors were encountered: