-- PROCEDURE: internal.presetsequence()

-- DROP PROCEDURE IF EXISTS internal.presetsequence();

CREATE OR REPLACE PROCEDURE internal.presetsequence(
	)
LANGUAGE 'plpgsql'
AS $BODY$
BEGIN
  perform setval('dbo.personsequence',(SELECT max(personid) FROM dbo.person), true);

  perform setval('dbo.schoolclasssequence',(SELECT max(schoolclassid) FROM dbo.schoolclass), true);

  perform setval('dbo.schoollearnersequence',(SELECT max(schoollearnerid) FROM dbo.SchoolLearner), true);

  perform setval('dbo.schoollearneryearsequence',(SELECT max(SchoolLearnerYearID) FROM dbo.SchoolLearnerYear), true);
 END;
$BODY$;
