aboutsummaryrefslogtreecommitdiffstats
path: root/mayor-orig/mayor-naplo/update/pre002468-1-intezmeny.sql
diff options
context:
space:
mode:
authorM.Gergo2019-03-08 21:20:34 +0100
committerM.Gergo2019-03-08 21:20:34 +0100
commitf51c9ed2abe5c68211bb3736be5f70b1fe2c9ec0 (patch)
treee13e60e4b94a3b58f1e2bfbe271102c8f04b67bd /mayor-orig/mayor-naplo/update/pre002468-1-intezmeny.sql
parentc76a004b0135786f2742283f8d5f917106f58bd8 (diff)
downloadmayor-f51c9ed2abe5c68211bb3736be5f70b1fe2c9ec0.tar.gz
mayor-f51c9ed2abe5c68211bb3736be5f70b1fe2c9ec0.zip
további rendrakás
Diffstat (limited to 'mayor-orig/mayor-naplo/update/pre002468-1-intezmeny.sql')
-rw-r--r--mayor-orig/mayor-naplo/update/pre002468-1-intezmeny.sql31
1 files changed, 31 insertions, 0 deletions
diff --git a/mayor-orig/mayor-naplo/update/pre002468-1-intezmeny.sql b/mayor-orig/mayor-naplo/update/pre002468-1-intezmeny.sql
new file mode 100644
index 00000000..48077c91
--- /dev/null
+++ b/mayor-orig/mayor-naplo/update/pre002468-1-intezmeny.sql
@@ -0,0 +1,31 @@
+
+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 ; //
+