LASEC
Fishstock code is for experimental (suffix E) or Crown (suffix C) quota
Some landings are to the experimental or Crown stock codes. For most purposes these landings should be considered to be from the normal stock. This check is done early so that landings are checked in subsequent landings checks.
-- © Copyright 2026 The Kahawai Collective
-- SPDX-License-Identifier: MIT
INSERT INTO grooming_rules
VALUES ('LASEC', 'edw', 'landings', 'Fix', 'Landings to Crown or experimental stock codes');
CREATE OR REPLACE FUNCTION LASEC() RETURNS VOID AS $$
INSERT INTO groomed.checks(code, "table", "column", id, orig, new)
SELECT 'LASEC', 'landings', 'fishstock_code', id, fishstock_code, RTRIM(fishstock_code,'E')
FROM groomed.landings
WHERE fishstock_code ~ 'E$';
INSERT INTO groomed.checks(code, "table", "column", id, orig, new)
SELECT 'LASEC', 'landings', 'fishstock_code', id, fishstock_code, RTRIM(fishstock_code,'C')
FROM groomed.landings
WHERE fishstock_code ~ 'C$';
UPDATE groomed.landings
SET checks = array_append(checks,'LASEC'),
fishstock_code = u.new
FROM groomed.checks u
WHERE u.code = 'LASEC'
AND u.column = 'fishstock_code'
AND groomed.landings.id = u.id
AND groomed.landings.fishstock_code = u.orig;
$$ LANGUAGE SQL VOLATILE;
SELECT LASEC();Effects of grooming