Skip to content
Snippets Groups Projects
TEMP_hotfix2.3.8.sql 1.5 KiB
Newer Older
-- НЕ ДОБАВЛЯЙТЕ ЭТИ ФУНКЦИИ В БАЗУ !!!!

CREATE OR REPLACE FUNCTION public.discipline_find(pstudyplanid integer, psemesterid integer, psubjectid integer, pexamtype exam_credit_grading_credit)
  RETURNS SETOF integer
LANGUAGE sql
AS $function$
--select public.discipline_find(
--	:pstudyplanid,	-- put the pstudyplanid parameter value instead of 'pstudyplanid' (int4)
--	:psemesterid,	-- put the psemesterid parameter value instead of 'psemesterid' (int4)
--	:psubjectid,	-- put the psubjectid parameter value instead of 'psubjectid' (int4)
--	:pexamtype 	-- put the pexamtype parameter value instead of 'pexamtype' (exam_credit_grading_credit)
--);
SELECT disciplines.ID
FROM disciplines
  INNER JOIN disciplines_study_plans ON disciplines.ID = disciplines_study_plans.DisciplineID
WHERE disciplines_study_plans.StudyPlanID = pStudyPlanID AND
      disciplines.SemesterID = pSemesterID AND
      disciplines.SubjectID = pSubjectID AND
      (disciplines.ExamType = pExamType or
       (disciplines.ExamType = 'credit' and pExamType = 'grading_credit'));
$function$;

-- НЕ ДОБАВЛЯЙТЕ ЭТИ ФУНКЦИИ В БАЗУ !!!!

CREATE OR REPLACE FUNCTION public.discipline_settypeunsafe(pdisciplineid integer, ptype exam_credit_grading_credit)
  RETURNS integer
LANGUAGE plpgsql
AS $function$
declare vRow int;
begin
  UPDATE disciplines
  SET examtype = ptype
  WHERE ID = pDisciplineID ;
  get diagnostics vRow = ROW_COUNT;
  RETURN vRow-1;
  EXCEPTION
  when others then RETURN -1;
END
$function$
;