aboutsummaryrefslogtreecommitdiffstats
path: root/mayor-orig/update/pre002189-3-intezmeny.sql
diff options
context:
space:
mode:
authorM.Gergo2018-07-06 11:14:41 +0200
committerM.Gergo2018-07-06 11:14:41 +0200
commit43de9af71f7f4ca5731b94a06d688ae8412ba427 (patch)
tree54835de1dfcda504c02da261f0dc26885aed2e89 /mayor-orig/update/pre002189-3-intezmeny.sql
parent50310b0e4513ee3fcce67351ae61e8fff851130e (diff)
downloadmayor-43de9af71f7f4ca5731b94a06d688ae8412ba427.tar.gz
mayor-43de9af71f7f4ca5731b94a06d688ae8412ba427.zip
2018/Feb/28 -i állapot hozzáadva, mint a módosítások kiindulási állapota
Diffstat (limited to 'mayor-orig/update/pre002189-3-intezmeny.sql')
-rw-r--r--mayor-orig/update/pre002189-3-intezmeny.sql32
1 files changed, 32 insertions, 0 deletions
diff --git a/mayor-orig/update/pre002189-3-intezmeny.sql b/mayor-orig/update/pre002189-3-intezmeny.sql
new file mode 100644
index 00000000..8894f44b
--- /dev/null
+++ b/mayor-orig/update/pre002189-3-intezmeny.sql
@@ -0,0 +1,32 @@
+drop function if exists diakNaploSorszam;
+
+ DELIMITER //
+ CREATE function diakNaploSorszam ( thisDiakId INT, thisTanev INT, thisOsztalyId INT ) returns INT
+ READS SQL DATA
+ BEGIN
+ DECLARE inKezdesDt,inZarasDt DATE;
+ DECLARE a,i INT; -- for loop
+ DECLARE b DATE; -- for loop
+ DECLARE cur1
+ CURSOR FOR
+ SELECT diakId,IF(beDt<inKezdesDt,inKezdesDt,beDt) AS d FROM osztalyDiak LEFT JOIN diak USING (diakId) WHERE osztalyId=thisOsztalyId AND beDt<=inZarasDt AND (kiDt IS NULL OR kiDt>inKezdesDt) ORDER BY d, CONCAT_WS(' ',viseltCsaladinev,viseltUtonev) COLLATE utf8_hungarian_ci;
+ DECLARE CONTINUE HANDLER FOR NOT FOUND RETURN NULL;
+
+ SELECT kezdesDt FROM szemeszter WHERE tanev=thisTanev AND szemeszter=1 INTO inKezdesDt;
+ SELECT MAX(zarasDt) FROM szemeszter WHERE tanev=thisTanev INTO inZarasDt;
+ SET i := 1;
+ OPEN cur1;
+ lo: LOOP
+ FETCH cur1 INTO a,b;
+ IF a = thisDiakId THEN
+ LEAVE lo;
+ END IF;
+ SET i := i+1;
+ END LOOP;
+ CLOSE cur1;
+ return i;
+ END; //
+ DELIMITER ; //
+
+-- Minta : select (70, 2010, 4);
+-- Minta: select osztalyNaploSorszamByDiak(diakId,2010,4) AS ns, diakId FROM osztalyDiak WHERE osztalyId=4 ORDER BY ns;