Document ID:        31200.1
Creator:            DAGREEN
Subject:            Abort Report if No Records Returned
Modified:           18 Nov 96 05:12:41


Question
~~~~~~~~
When calling Reports 2.5 from Forms 4.5 with Run_Product
command, passing some parameters, if the report runs with no
records returned, is it possible to stop it from showing the
empty output in the previewer ? (in other words to cancel the
report output after finding that 0 records returned)

Answer
~~~~~~
Create a 'Before Report' trigger that counts the number of records
you'll be getting back [Copy the SQL from the query]. Cancel the
report execution with a call to the build-in SRW.PROGRAM_ABORT.

        Function BEF_REP_TRG return boolean is
           count_inv number;
        begin
            select count(inv_no) into count_inv from invoices
               where :P_invoices= .... ;
            if count_inv = 0 then
               srw.message (1009, 'No invoices found for printing');
               return false;     /*   or use SRW.PRORAM_ABORT;   */
            end if;
            return true;
        end;

If you do not want to see any dialogs show up from Forms use
batch=yes when calling reports.