Popular Posts
javax.net.ssl.SSLHandshakeException: Connection closed by peer in Android 5.0 Lollipop Recently, there is a error occurs when access website via ssl connection like below although it worked fine several days ago. // Enable SSL... Tired of Hibernate? Try JDBI in your code JDBI Quick sample ICategoryDAO.java : create a data access interface (implement is not required) package com.prhythm.erotic.task.data.... Enable SSL connection for Jsoup import org.jsoup.Connection; import org.jsoup.Jsoup; import javax.net.ssl.*; import java.io.IOException; import java.security.KeyManagement...
Stats
Temp table sample
MySQL
-- Procedure "IsActionAllowed" DDL

CREATE DEFINER=`root`@`%` PROCEDURE `IsActionAllowed`(IN roleid CHAR(36), IN functionid CHAR(36))
BEGIN
    DECLARE rid CHAR(36);
    DECLARE base_role CHAR(36);
    DECLARE exist INT;

    CREATE TEMPORARY TABLE TempTable (RID CHAR(36)) TYPE=INNODB;

    INSERT INTO TempTable VALUES(roleid);
    SET base_role = '';
    SET rid = roleid;

    WHILE base_role IS NOT NULL DO
        IF base_role <> '' THEN
            INSERT INTO TempTable VALUES(base_role);
        END IF;

        SELECT
            tbl_roles.BASE_ON_ROLE INTO base_role
        FROM
            tbl_roles
        WHERE
            tbl_roles.ROLE_ID = rid;

        SET rid = base_role;

    END WHILE;

    SELECT
        COUNT(tbl_role_permission.ROLE_ID) INTO exist
    FROM
        tbl_role_permission
    WHERE
        tbl_role_permission.ROLE_ID IN (SELECT * FROM TempTable)
        AND tbl_role_permission.FUNCTION_ID = functionid;

    DROP TEMPORARY TABLE IF EXISTS TempTable;

    IF exist > 0 THEN
        SELECT true AS Allowed;
    ELSE
        SELECT false AS Allowed;
    END IF;
END;
Procedure tutorial : Stored Procedure Parameters