insert email into borrower_message_preferences
[ferlib2koha.git] / fer_upisani.sql
1 -- import students enrolled for this year
2
3 drop table fer_upisani_2011 ;
4
5 create table fer_upisani_2011 (
6         jmbag varchar(10) primary key,
7         ime text not null,
8         prezime text not null,
9         nick text,
10         email text
11 );
12
13 LOAD DATA INFILE '/srv/ferlib2koha/report_62836_1026_Aktivni_studenti.unl' INTO TABLE fer_upisani_2011
14   FIELDS TERMINATED BY '#'
15   LINES TERMINATED BY '\r\n'
16 ;
17
18 select count(*) from fer_upisani_2011
19
20 exit
21 end
22
23 -- students to expire
24 select borrowernumber,userid,email,dateexpiry
25 from borrowers
26 where categorycode='S' and length(userid) > 0 and dateexpiry > '2011-09-30'
27 ;
28
29 -- students to enroll
30 select borrowernumber,userid,dateexpiry,jmbag,nick
31 from borrowers
32 full join fer_upisani_2011 on nick = userid
33 where categorycode='S' and length(userid) > 0 and dateexpiry > '2011-09-30' ;
34
35 begin;
36
37 update borrowers
38 set dateexpiry='2011-09-30'
39 where categorycode='S' and length(userid) > 0 and dateexpiry > '2011-09-30'
40 ;
41
42 update borrowers,fer_upisani_2011
43 set dateexpiry='2012-10-31'
44 where categorycode='S' and length(userid) > 0 and nick = userid
45 ;