Académique Documents
Professionnel Documents
Culture Documents
x NOTE: See TN6200-007-0010 and TN6200-007-0013 for information on different methods for alert services, their advantages, disadvantages and the steps involved. The solution proposed in TN6200-007-0010 involves the creation of an event table in the warehouse. The creation of new attributes and facts, a new report based off those attributes that must be included in the publication and the inclusion of a Post Structured Query Language (SQL) statement in the Subscription set for the service created. The second solution proposed in this document is easier to implement and maintain. It optimizes system resources and is based on the use of Pre and Post SQL statements that are appended to a subscription set for a service, without having to create any new objects in the MicroStrategy 8.x project. SOLUTION: This process requires the particular event (such as a warehouse load) to create a flag in the warehouse or any database after it finishes execution. Then, the services created with MicroStrategy Narrowcast Server need to have some PRE execution SQL in the subscription set, with the Pre-SQL Service Execution Impact set to 'Required'. The Pre-SQL statement runs against this flag in the warehouse and forces the service to halt execution if the query returns an error. EXAMPLE I: This example requires the particular event (such as a warehouse load) to create a dummy table (in this example, the whole dummy table serves as the flag mentioned above) in a database after it finishes execution. Then, the services created with MicroStrategy Narrowcast Server need to have some PRE execution SQL to check for the existence of this dummy table. When a scheduled service executes, as a first step, it connects to any database using a specified Data Source Name (DSN) and runs a (pre) SQL such as 'Select * from TableEvent1'. If the event is not finished, the dummy table does not exist; and the SQL statement fails with the error 'Invalid Object'. With the Pre-SQL impact set to 'Required', the service halts its execution with an error ('Invalid Pre- Execution SQL'). In this case, no e-mail is sent and no jobs are run against the warehouse. If the event is finished and it has created the dummy table, the service executes, connects to the database using the specified DSN and runs a (pre) SQL such as 'Select * from TableEvent1'. Since the table is there, the SQL statement does not fail and the service continues with its execution. The use of a POST SQL such as ('Drop Table TableEvent1'), after the Services has finished its execution, deletes that event dummy table so that the service does not execute until the next BatchLoad (or event) occurs and the dummy table is created again. It is important to consider that if more than one service is going to be triggered by the event, a table for each of these services must be created. The SQL statement included in the script for the event must create as many EVENT tables as services depend on that event. EXAMPLE II: This example includes the creation of a Stored Procedure in SQL Server that returns an error if the particular event is not completed. Thus, preventing the service execution. The event has taken place if the Stored Procedure returns a success value. Perform the following steps.
1. Create the table: create table event (event_flag int) 2. Insert a value: insert into event values (0) 3. Create the stored procedure: create procedure puedo as begin DECLARE @del_error int select @del_error = event_flag from event where event_flag=0 IF @del_error = 0 RAISERROR ('You can''t run anything now', 16,1) end 4. Specify the Pre-Execution SQL: exec puedo 5. Specify the Post-Execution SQL: insert into event values (0) This procedure declares a variable and it assigns a SQL query to that variable. Then, the procedure does a validation that returns an error if the query produces a specific value. Otherwise, the procedure is completed successfully. NOTE:
Users may need some modifications for this procedure if they have several event-based services. However, the logic remains the same. Rather than using the above stored procedure, users can design different methods to make pre-SQL fail when the alert condition is not met. For example, have a column return '0' if the alert condition is not met and '1' if it is met in the above code. Create a SQL statement that will cause a division by zero as follows. Then, divide by that returned 1 or 0 to make the statement fail or not fail. select (10.0 / event_flag) from event
CONCLUSION: The maintenance cost of these examples is minimal since no objects need to be created in the MicroStrategy 8.x project(s) that MicroStrategy Narrowcast Server uses as Information Source.
The particular event needs to create a flag (can be a dummy table, a column value for an existing EVENT table, etc.) and pre-SQL can check the flag. If the alert condition is not met, pre-SQL should fail and prevent the service from running. Otherwise, the service will be run and postSQL will reset the flag. Therefore, the maintenance on the database is kept to the minimum. Another advantage of this approach is that no unnecessary jobs will be run against the MicroStrategy Intelligence Server or warehouse, optimizing system resources. With the previous method, the reports included in a Service as Information Objects as well as the alert report would be executed and, depending on the results for the alert report, the results for all the other ones were broadcasted or not. This method consumes system resources even when the service is not sent. WARNING: Manually editing values in the database may cause serious, project-wide problems that may make your project unusable. Since these are user initiated changes they are not covered by any MicroStrategy warranty. Users are strongly encouraged to backup their database prior to any alteration.
1. TN4615: Achieving event-based services with MicroStrategy Narrowcast Server 8.x Abstract: This document discusses an approach to achieve event-based alerts for services sent with Micr Narrowcast Server 8.x. Date: 06/28/2009 100% of users found this TN useful
2. TN5891: How to implement event based alerts in MicroStrategy Narrowcast Server Abstract: This document offers a method of implementing event based (i.e., Alert) services in MicroStra Narrowcast Server by forcing a SQL error, causing Narrowcast Server to halt service execution. Date: 06/28/2009 Be the first to rate this TN
3. TN7766: How to achieve event-based alerts with MicroStrategy Narrowcast Server 7.x using the select f existent table pre-SQL and IBM DB2 Archived Document Abstract: This document describes one method of achieve event-based alerts using MicroStrategy Narro Server 7.x and IBM DB2. Date: 12/20/2007 Be the first to rate this TN