From 08242c437d1196ba5848c88b13577caeba7d04db Mon Sep 17 00:00:00 2001 From: Mario Voigt Date: Fri, 30 Nov 2018 15:42:31 +0100 Subject: [PATCH] =?UTF-8?q?=E2=80=9EREADME.md=E2=80=9C=20=C3=A4ndern?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/README.md b/README.md index add23b3..e1519b0 100644 --- a/README.md +++ b/README.md @@ -150,6 +150,32 @@ CREATE TABLE IF NOT EXISTS SmartlockAuth `updateDate` DATETIME NOT NULL ); + +DROP FUNCTION IF EXISTS DaysFromBitMask; +@delimiter ++; +CREATE FUNCTION DaysFromBitMask (val INT) +RETURNS VARCHAR(255) DETERMINISTIC +BEGIN + DECLARE DAY_RESULT VARCHAR(255); + SET DAY_RESULT=""; + IF val = 0 THEN SET DAY_RESULT='Keine'; END IF; + IF val >= 64 THEN SET DAY_RESULT='Mo'; SET val=val-64; END IF; + IF val >= 32 THEN SET DAY_RESULT=CONCAT('Di',', ',DAY_RESULT); SET val=val-32; END IF; + IF val >= 16 THEN SET DAY_RESULT=CONCAT('Mi',', ',DAY_RESULT); SET val=val-16; END IF; + IF val >= 8 THEN SET DAY_RESULT=CONCAT('Do',', ',DAY_RESULT); SET val=val-8; END IF; + IF val >= 4 THEN SET DAY_RESULT=CONCAT('Fr',', ',DAY_RESULT); SET val=val-4; END IF; + IF val >= 2 THEN SET DAY_RESULT=CONCAT('Sa',', ',DAY_RESULT); SET val=val-2; END IF; + IF val >= 1 THEN SET DAY_RESULT=CONCAT('So',', ',DAY_RESULT); SET val=val-1; END IF; + /*Wenn val nicht mit "Keine" oder mit "Mo" endet, dann das Komma+Leerzeichen abschneiden*/ + SET DAY_RESULT = CASE WHEN DAY_RESULT LIKE '%, ' THEN LEFT(DAY_RESULT,length(DAY_RESULT)-2) ELSE DAY_RESULT END; + RETURN DAY_RESULT; +END +++ +@delimiter ;++ +GRANT EXECUTE ON FUNCTION DaysFromBitMask TO nuki; +/*Test the function with some int values via SELECT DaysFromBitMask(yourValue);*/ + + /*look script: you need to insert the nukiId in jq*/ CREATE TABLE IF NOT EXISTS BridgeCallbackList