Skip to content
Snippets Groups Projects
Commit 45376484 authored by Anton Bagliy's avatar Anton Bagliy
Browse files

Merge branch 'issue335_copy_map' of gitlab.mmcs.sfedu.ru:it-lab/grade into issue335_copy_map

parents 2aeb572b 8ecd8960
Branches
Tags
No related merge requests found
CREATE OR REPLACE FUNCTION public.copy_map(withukd integer, withoutukd integer)
RETURNS integer
LANGUAGE plpgsql
AS $function$
--declare maxrate1 int default -1; maxrate2 int default -1; examtype1 exam_credit_grading_credit default null; examtype2 exam_credit_grading_credit default null;
declare newid int default -1; keyid int default -1;
crsModules cursor for select modules.id, modules."name", modules.ordernum, modules."type"
from modules
where modules.disciplineid=withukd and modules.ordernum!=3141592 and modules.ordernum!=2900666; -- exam and extra
crsSubmodules cursor for select submodules.maxrate, submodules.ordernum, submodules."name", submodules.description, submodules.isused, submodules."type"
from submodules
where submodules.moduleid=keyid;
begin
/* select maxrate, examtype into maxrate1, examtype1
from disciplines where id=withukd;
select maxrate, examtype into maxrate2, examtype2
from disciplines where id=withoutukd;
*/
--if (maxrate1=100 and maxrate2!=100 and examtype1=examtype2 and examtype1 is not null) then
for mdl in crsModules loop
keyid=mdl.id;
insert into modules("name", ordernum, disciplineid, "type")
values(mdl."name", mdl.ordernum, withoutukd, mdl."type") returning id into newid;
for sbmdl in crsSubmodules loop
insert into submodules(moduleid, maxrate, ordernum, "name", description, isused, "type")
values(newid, sbmdl.maxrate, sbmdl.ordernum, sbmdl."name", sbmdl.description, sbmdl.isused, sbmdl."type");
end loop;
end loop;
return 0;
--end if;
return -1;
end
$function$;
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment