


-- Inserted at 2010-04-29T16:50:01.346+01:00

alter table `COMPETENCE_COURSE_INFORMATION_CHANGE_REQUEST` add column `OID_COMPETENCE_COURSE_GROUP_UNIT` bigint(20);
alter table `COMPETENCE_COURSE_INFORMATION_CHANGE_REQUEST` add index (`OID_COMPETENCE_COURSE_GROUP_UNIT`);


drop temporary table IF EXISTS XPTO;

create temporary table XPTO select distinct Request.OID as OID, Information.OID_COMPETENCE_COURSE_GROUP_UNIT as OID_COMPETENCE_COURSE_GROUP_UNIT from COMPETENCE_COURSE as Course, COMPETENCE_COURSE_INFORMATION as Information, COMPETENCE_COURSE_INFORMATION_CHANGE_REQUEST as Request where Course.OID = Information.OID_COMPETENCE_COURSE and Course.OID = Request.OID_COMPETENCE_COURSE;
update COMPETENCE_COURSE_INFORMATION_CHANGE_REQUEST as Request set Request.OID_COMPETENCE_COURSE_GROUP_UNIT = (select XPTO.OID_COMPETENCE_COURSE_GROUP_UNIT from XPTO where Request.OID = XPTO.OID);

