Delimiter //
/**
	Procédure qui supprime toutes les tables d'accréditation pré-calculé des membres
*/
Drop Procedure if Exists BUSINESS_COMPUTE_MEMBERS_CREDENTIALS_CLEAR_ALL//
 
Create Procedure BUSINESS_COMPUTE_MEMBERS_CREDENTIALS_CLEAR_ALL()
Begin
    memberCredentialClearAll: begin
		Declare credentialTblName varchar(50);
		Declare credTblLstCursor Cursor For
			Select 
				TBLS.`TABLE_NAME`
			From information_schema.TABLES TBLS
			where TBLS.TABLE_SCHEMA = schema()
				And TBLS.`TABLE_NAME` like 'TMP_%_CREDENTIALS_MEMBER__%'
			;
		Open credTblLstCursor;
		credTableBlk: Begin
			Declare Exit Handler for NOT FOUND 
                Begin
                    Close credTblLstCursor;
                End ;
			credTableDropLoop: loop
				fetch credTblLstCursor Into credentialTblName;
				set @query = Concat('Drop Table if exists ', credentialTblName);
		        PREPARE credTblDropStmt FROM @query; 
				execute credTblDropStmt 
					;
				Deallocate prepare credTblDropStmt; 				
			End loop credTableDropLoop;
		End;

# 		Drop Temporary table If exists TMP_DF_ACCESS_PROFILES1;
# 		Drop Temporary table If exists TMP_DF_ACCESS_PROFILES2;

    end ;
end //
Delimiter ;

