I have scheduled a report that send out mail on daily basis with an attachment. Problem is even if there is no data, email goes out with blank attachment.
I am using BO XI R2, is there any way to do this.
While searching on this forum, I came across similar topic suggesting a object to be built in universe. I am not interested to do this. Please let me know if there is any work around.
You explained it fine the first time. What Damocles is saying is that it’s a user training\expectation issue. Better to receive a report with no data rather than not receive the report at all. That way you know the report ran successfully.
I was able to implement the same kind of thing using File event and batch jobs.
I setup the job to wait for a trigger file using File Event.
I extracted the SQL from the report in question then I setup a batch job that runs the SQL. If there is data the batch job FTPs a trigger file into the server.
You have to make sure of two things though:
Your report should be scheduled to start before your batch job finishes.
Make sure you have another batch job that deletes the trigger file before your schedule starts.
I agree there is risk in any of those batches failing, but we usually have paging capability in all our batches. In case of failure they do notify support team.
I am using Oracle DB and XIR2. I successfully created similar reports, with the help some previous posting and some of my thinking.
I tried the file event and thought I can do in a different way.
I created a variable in Univerese.
Name: RowCount
Type: Dimension or Measure
Data Type - Number
Comment: Returns row count if more than 1 row. Otherwise, throws database error. Forces a query to fail if NO rows returned. Helps to control report distribution based on rows returned
CASE count(1)
WHEN 0 THEN TO_NUMBER(‘error’ )
ELSE 1 END
AS int_type
In the report, duplicate the query and replace the selected objects with the new “rowcount” object. (This is to ensure the filter conditions are retained)
I named this query as “force to fail”
In the CMC, Object properties -> Schedule (tab) ->Notification (sub tab) , set notification as “Email notification based on” and configure the person to whom it should notify in case of ERROR
then shedule the doc as usual.
Hope this is simple than file event and guess, it should fit most of the scenarios.
Guna,
This looks like a clever way to force the failure. Only reservation I have is when the report fails to run you won’t know if it’s because of no data returned or some other reason.
I’m looking for a way to force Webi reports to fail if they exceed a specific row count. We want this to apply to ad hoc as well as scheduled reports. We want to force the reports to fail because we don’t trust that users will pay attention to the “partial results” warning that displays on reports if you set the limit on the report on or the universe. Do you know of a good way to do this? We’re on XIr2 with Oracle 10g. It apparently cannot be done on the database side.
I am trying to implement vigi_guna’s suggested approach. My universe object looks like this (SQL Server 2005):
CASE count(1)
WHEN 0 THEN CONVERT(int,'error')
ELSE 1
END
The object does not parse in Designer. When I refresh the report in Webi 3.0, it returns an error "A database error occured. The database error text is: [Microsoft SQL Native Client] : Conversion failed when converting the varchar value ‘error’ to data type int… (WIS 10901).
My query is a “Union All” query that brings back results from an active table and an archive table in the same data provider. I only want to throw the error if I have 0 records returned from “BOTH” queries. The problem with this approach is it will fail if either query returns 0 records.
Any thoughts on how I might use this with union queries in Webi?
I have been using a technique that is not WOW but it works. The basic idea is based on the fact that if the report fails then it is not sent it. So, if you force a failure when no records are returned you get the solution.
Now, if you put this simple formula in the report footer:
1/if isnull (Count ({yourdatabase.yourfield}))= true then 0 else 1
// if no records the report will fail because a division by zero and the email will not be sent.
// if at least one record the report will not fail and the email will be sent.
I call this formula “Conditioned error to prevent the delivery of an empty report”.
Optional consideration:
Because I use the report for both “On demand” and “schedule” modes, I added a parameter asking for something like "Do you want to see blank reports? Y/N. The above formula will be evaluated or not based on the answer.
Try the below approach instead of creating a variable in the footer.
In Webi Rich Client, create a new Data provider(DP2) with one measure object only. Goto ‘View SQL’ and select ‘Use Custom SQL’ and override the sql with the below code.
SELECT
CAST(CASE count() WHEN 0 THEN ‘0 rows returned forced SQL error’ ELSE count() END AS int)
FROM (copy and paste the FROM and WHERE condition of Data provider 1)
When DP2 runs and returns 0 records, the report fails and doesn’t send it to the user.
When DP2 runs and returns the count of rows then it sends report to the user.
Based on your information, i have created the data provider and copy the sql query and paste it. It will work with static input, But where the user inputs are dynamic(prompt), the query,
(copy and paste the FROM and WHERE condition of Data provider 1)
give an error like “Cannot generate the SQL, Please contact your BO Administrator.”