Fully automated report generation and email

I am trying to get a report (from a query) to run automatically every Tuesday morning.
This is my job
BEGIN
     dbms_scheduler.create_job (
          job_name          => 'GEN_XLS_RPT_AND_EMAIL',
          job_type          => 'STORED_PROCEDURE',
          job_action          => 'gen_bomreport_proc',
          start_date          => to_timestamp('05-12-2009 07:00','DD/MM/YYYY HH24:MI'),
          repeat_interval     => 'FREQ=DAILY; BYDAY=TUE; BYHOUR=7',
          enabled               => true,
          comments          => 'Weekly CSV Reports Output at 7:00AM'
END;Then I have a procedure
PROCEDURE gen_bomreport_proc IS
DECLARE
    l_id number;
    l_document BLOB;
BEGIN
     l_document := APEX_UTIL.GET_PRINT_DOCUMENT (
          p_application_id          => 109,
          p_report_query_name          => 'qry_Report_1week',
          p_report_layout_name     => 'qry_Report_1week',
          p_report_layout_type     => 'application/excel',
          p_document_format          => 'xls'
     l_id := APEX_MAIL.SEND (
          p_to        => 'to@me',
          p_from      => 'from@you',
          p_subj      => 'Weekly Report',
          p_body      => 'Please review the attachment.',
          p_body_html => 'Please review the attachment'
   APEX_MAIL.ADD_ATTACHMENT (
       p_mail_id    => l_id,
       p_attachment => l_document,
       p_filename   => 'report_' || to_char(sysdate-8, 'YYYY') || '_' || to_char(sysdate-8, 'DD-MM') || '-' || to_char(sysdate-1, 'DD-MM') || '.csv',
       p_mime_type  => 'application/excel');
END;And the query that is supposed to get ran to generate the report saved as 'qry_Report_1week'
SELECT organization_name, quote_description, quote_name, quote_pwd, user_id, contact_last_name || ', ' || contact_first_name contact_name,
  email, create_date, qty, unit_price, ext_price, discount_percent, company_name, item_no, supplier_name, product_category, mfg_part_no,
  quote_id, customer_id, exalt_user_id
FROM bom_detail_cdw2
where create_date BETWEEN sysdate-8 and sysdate-1 order by create_date;I tried running the job
begin
DBMS_SCHEDULER.RUN_JOB (
   job_name => 'GEN_XLS_RPT_AND_EMAIL',
   use_current_session => false);
end;I read a lot about scheduler, APEX_UTIL.GET_PRINT_DOCUMENT and APEX_MAIL.ADD_ATTACHMENT, but I'm sure I missed something. Any help would be appreciated... Thanks

Thanks Vorlon, your link was a bit helpful.
Alright, I am making progress, but have had to come up with an alternative to the Report Query as found out that you need BI and we don't (and won't) have that.
Option 1: dump the query result in a csv file
Problem: I can't attach the csv to the email
CREATE OR REPLACE PROCEDURE gen_bomreport_proc
AS
     l_report  BLOB;
     f_report  UTL_FILE.file_type;
     bomdata_buf VARCHAR2(24000);
     bomdata_header VARCHAR2(512);
     l_id number;
     CURSOR bomdata_cur IS
          SELECT * FROM BOM_DETAIL_CDW2
          where create_date BETWEEN (sysdate-8) and (sysdate-2) order by create_date;
BEGIN
     -- Create and populate file
     f_report := UTL_FILE.fopen ('TESTDIR','bom_output.csv', 'W');
     bomdata_header := 'Organization,Description,Quote Name,Quote PWD,User ID,Email,Created,QTY,Unit Price,Ext Price'||
          ',Disc. %,Address,' || 'Item No,Mfg Part No,Contact Name,Supplier Name,Product Category,Quote ID,Customer ID,Exalt User Id' || chr(10);
     UTL_FILE.PUT_LINE(f_report, bomdata_header);
     FOR bomdata_rec IN bomdata_cur LOOP
          bomdata_buf := bomdata_rec.organization_name || ',' || REPLACE(bomdata_rec.quote_description,',','') || ','
          || bomdata_rec.quote_name || ',' || bomdata_rec.quote_pwd || ',' || bomdata_rec.user_id || ','
          || bomdata_rec.contact_first_name || ' ' || bomdata_rec.contact_last_name || ',' || bomdata_rec.email || ','
          || bomdata_rec.create_date || ',' || bomdata_rec.qty || ',' || bomdata_rec.unit_price || ',' || bomdata_rec.ext_price
          || ',' || bomdata_rec.discount_percent || ',' || bomdata_rec.company_name || ',' || bomdata_rec.item_no || ','
          || bomdata_rec.supplier_name || ',' || bomdata_rec.product_category || ',' || bomdata_rec.mfg_part_no || ','
          || bomdata_rec.quote_id || ',' || bomdata_rec.customer_id || ',' || bomdata_rec.exalt_user_id;
      UTL_FILE.PUT_LINE(f_report, bomdata_buf);
    END LOOP;
     -- Part where I convert UTL_FILE.file_type into a BLOB and store in l_report ?? --
     UTL_FILE.FCLOSE(f_report);
     -- End
     -- email part - I'm ok here
END;ok, so there's a line:      -- Part where I convert UTL_FILE.file_type into a BLOB and store in l_report ?? -- which I have searched for, to no avail
Option 2: dump the query result in a BLOB
Problem: I need to write strings/literals into the BLOB, but it keeps throwing the error PLS-00382: expression is of wrong type, when I write something like:
DECLARE
     l_report BLOB;
     bomdata_buf VARCHAR2(24000);
     bomdata_header VARCHAR2(24000);
BEGIN
     bomdata_header := 'Organization,Description,Quote Name,Quote PWD,User ID,Email,Created' || chr(10);
     l_report := bomdata_header;
END;

Similar Messages

  • PDF Report generation and email it from a DB trigger

    Dear all
    Is it possible to run a report in PDF format ad email it to some clients after a specific envent through Database Trigger. For example whenever a client makes an entry into order entry table (through entry form), a trigger should execute on Orders table, this trigger should execute or generate a PDF formatted report and finally mail it to Sales team?
    I'm using Oracle Database 10g. Rel.2 on Windows-XP.

    kamranpathan wrote:
    Is it possible to run a report in PDF format ad email it to some clients after a specific envent through Database Trigger. No. Not the way you imagine.
    A trigger is fired when? During the transaction. The transaction still is not committed and can be rolled back. So if you start doing notifications and what not in the trigger, and the transaction is rolled back, then that transaction never happened. But your notification code did. And the users have been informed incorrectly - about something that did not happen.
    The same trigger can also be fired in the same transaction for the same row - more than once. This can happen in specific circumstances in Oracle, where basically Oracle itself does an undo of the transaction (trigger already fired) and then redo that transaction (trigger fire again).
    So in such a case, your trigger will generate two notifications from the same trigger for the same event. Inside a transaction that still could be rolled back by the session owner.
    The correct approach is not to perform the action in the trigger. It is to queue the action to be executed when the transaction is committed.
    For example, the trigger is on the PRODUCTS table. When a new product is added, a notification needs to be send to customers that have selected to be informed of new product releases.
    The first step is to write a package that performs this notification. The procedure that drives the notification processing, gets a product identifier as input and does the checks and notification.
    After this package has been tested, it is implemented indirectly via a trigger on the PRODUCTS table. Instead of the trigger directly calling this package, the trigger needs to queue an action that will execute the notification package when the transaction is committed.
    This can be done using DBMS_JOB. In the trigger, a job is submitted to execute that notification package for the current product ID. The job submission is part of the existing transaction. If the transaction is rolled back, so is the job and it is removed from the job queue. If the transaction is committed, the job is also committed to the job queue and executed.

  • Query for report generation and email alert

    Hi,
    I do have a requirement in my project like the following.
    1. We do have multiple interfaces sending request to one of the target Webservices
    2. Receiving response back from Webservices
    3. Also logging the same using log4J
    My requirement is to filter out response messages based on particular interface(Lets say Order status) using name/ timestamp for particular day, save/append all responses in to a file and should send an email report at a given point of time.
    Report has to generate once in a day E.g Time: 00:00 AM every day.
    Is that possible to achieve the same through ALSB(Aqua Logic Service Bus). Please help us in implementing this requirement.
    Thanks in advance,
    Krishna

    You probably concentrate too much on OSB. I see two issues:
    1. Appending everything into a single file. I have never tried file transport, so I don't know if this is possible or not, but looking at documentation I don't think its possible:
    http://download.oracle.com/docs/cd/E13159_01/osb/docs10gr3/httppollertransport/transports.html#wp1081043
    2. As far as I know there is no support for scheduling in OSB.
    I don't know your situation and requirements, but you should rather implement your reporting logic outside of OSB. For example you can filter response messages in OSB and "log" them through a logging web service (service callout in alsb). That service could accumulate your report in a file and send it with the first request each day. This approach could eliminate usage of any scheduling component.
    Personally, if I were you I would thing about my infrastructure logging capabilities on proxy server, http server or whatever is in use. Combined with unix cron daemon, the solution could be very easy and straight-forward.

  • Exe giving error for report generation and LV 8.6.1

    I have created and installed a labview application in a PC(windows XP) where labview is not installed.  (already included NI_Excel.lvclass)
    I have used a report(excel) generation to display the results.
    I am getting following error:
    Error Code: -2147352573
    Member not found in NI_Excel.lvclass:
    I am using MS office Excel 2007 SP1
    NI LabVIEW Run-Time Engine:8.6.1.
    Report generation toolkit version:1.1.3
    phani srikanth
    Solved!
    Go to Solution.
    Attachments:
    Error.JPG ‏10 KB

    search the ni website and a 30 day eval copy can be found. For use beyond this period you would have to buy a license (unless you have one of course)
    compatibility can be found on the following link
    http://digital.ni.com/public.nsf/allkb/C9408B9F08D711E786256F3300701D01 
    hope it helps
    TD 
    Please remember to accept any solutions and give kudos, Thanks
    LV 8.6.1, LV2010,LV2011SP1, FPGA, Win7

  • What diff between BIP AttachEntity Report Generation and BIP Report Generation?

    Hi all,
    I want to know the two WF has what's difference.
    I had seen they have same method and step.
    Actually,I want to do a function, when click a button,will generate BIP reports.
    Using the BIP Report Gneration can do this.
    But I want pop a window to open or save the report after the WF finished work.
    Could  BIP AttachEntity Report Generation  do that?
    I had similitude it seem same as BIP Report Gneration.
    Be appropriate to you if you can answer the question.
    Thanks,
    Wenqin

    Ok, let me guess, you are seeing an error that says an invalid printer was selected, right? Well there is a bug in your code but it has nothing to do with the printer that you have selected. Specifically you have some of the margin values set to zero -- which is invalid. The margins have to have a value of at least 1. In case you're interested, I followed down the logic and inside the print report VI the code, for some unknown reason (NI is checking into it), remapps an error code that correctly identifies invalid margins to report one that reports an invalid printer name. Apparently this was first reported in 2008.
    Verified this behavior of both LV2013 and 2014.
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • Automating Report Creation and Distribution in B1

    I am creating a Sales Report for all Sales Reps. Management wants to break the report into separate PDFs, one for each Rep and email the reports to those reps.  Is there a way to automate the whole process so one click will create the reports and email it.
    Thanks for your help.

    Hi,
    1. If you report is based on query, you can separate report for each sales rep.
    2. There is no automatic option to separate and email crystal report in standard SAP b1.
    3. You may try to post such requirement at SDK forum to get some idea.
    My suggestions is, create separate query for each sales rep and schedule and email to this report by using standard b1 functionality.
    You can also group each report in to one report to present for your management.
    Thanks & Regards,
    Nagarajan

  • Report generation and office versions

    I have developed an application which uses the excell report generation features.  I have Office 2007 on my pc with LV 8.51 and report generation addon 1.1.2.  I wand to distribute (build) the application to users with office 2000.  What steps need to be done.  Do I need 2 different builds, will one build work?  How do I specify which version of the office gets linked, is this dynamic?
    Paul Falkenstein
    Coleman Technologies Inc.
    CLA, CPI, AIA-Vision
    Labview 4.0- 2013, RT, Vision, FPGA

    Hi Paul.
    Thanks for the reply.
    When building applications with Report Generation Toolkit VIs, you must complete the following additional steps:
    • From the Source Files tab of the Build Application or Shared Library (DLL) dialog box, click the Add Dynamic VI button to
    add the following two VIs to the application:
    – _Excel Dynamic VIs.vi in vi.lib\addons\_office\_exclsub.llb
    – _Word Dynamic VIs.vi in vi.lib\addons\_office\_wordsub.llb
     Note, you'll need to add the VI's for both versions. You may need to re-name the vi.lib, because they'll have the same name (i think) but the references etc for different office versions do change and hence we you need to call different vi's.
    • If the application you are building contains the MS Office Report Express VI, you must add any Word or Excel templates that you use to the built application. From the Source Files tab, click the Add Support File button to add the template files to the application. By default, the custom destination for the templates is the same as the path that appears in the Destination directory field on the Target tab with a data subdirectory appended. Do not change the custom destination for the files you add.
    For example, if you are using the basic Excel template with the MS Office Report Express VI, add MSOffice_RGT_Template.xlt to the application. The basic template files are located in the
    templates\Report directory.
    Hope this explains it a little better,
    Kind Regards
    James Hillman
    Applications Engineer 2008 to 2009 National Instruments UK & Ireland
    Loughborough University UK - 2006 to 2011
    Remember Kudos those who help!

  • Automating a Parse-and-Email Process

    I have a 100-page report in Adobe Acrobat Pro 10. Each page includes a distinct email address and is intended for a distinct recipient. I need to extract each page from the report as a separate pdf file, rename each page with the email address contained within it and email each page separately in MS Outlook 2010.
    If anyone has already written a script for this sort of task, I'd greatly appreciate seeing it! Otherwise, where should I begin in trying to automate this process? I figure its most appropriate to write a program to do this for me, if so, which language should I use?
    Thanks!

    AppleScript can do stuff like this, although you will need to be a bit more specific about your data formats. I read that your desired script will:
    1) Read a specified (or asked for) data file;
    2) Get specified (or asked for) file names;
    3) Find a match between some part of a record in the data file and some part of a file name;
    4) On a match, append a description text specified in the record to the file name;
    5) Move the renamed file to a location specified in the record.
    You will need to define the format of the records in the data file, including the line endings and item delimiters, and the various portions of each record that will be used. Other items that need some clarification are things like error handling, such as what if there is a file with the same name in the destination folder or what if a record does not have all of the items.

  • Password Protect Report Exports and Email

    Hi there
    My client's requirement is to automatically run, export and email reports with the report output (excel/word/etc) having password protection. Think this is possible with BI publisher, but wondering if there is any nifty way of doing this with Discoverer. For example now Discoverer is integrated with BI Publisher does this mean it's possible by creating report in Disco (potentially) then using BI Pub to automatically run, export and email results with pwd protection? Any other ideas??
    This is an eBusiness Suite environment, Disco version 10.1.2, eBusiness Suite version 11.5.10 (they also have 11.5.8, but we don't believe we'll be doing this solution on tha environment).
    Cheers, Kate

    Hi,
    I don't think there is any easy solution to this, but what we do at this site is schedule the Discoverer reports to run using the eBusiness Suite Concurrent Manager. We use dedicated Discoverer workstations to run the Discoverer exports and these could also be used to email the report if this was a requirement.
    There is an article on my website (www.cabotconsulting.co.uk) about scheduling Discoverer reports using the Applications 11i concurrent manager and you can also search this forum for scheduling and email for information on how to email reports.
    Hope that helps,
    Rod West

  • How do I read a word file with Report Generation and Labview?

    Hello All:
    I have Labview 2010.
    How do I Read a Microsoft Word File1.doc with Labview and Report Generation Kit?
    File1.doc is a simple file with a few lines and a Table.
    thank you very much.
    \\diego2000

    I don't think that toolkit will help you.  Remember, it's the Report GENERATION Toolkit.  It's designed to create reports not read existing DOCs.
    You can use the standard file VIs to read a Word Doc but you'll have to strip out the formatting information to get at the raw text.
    There may be some other tools or ActiveX techniques that will help.  Hopefully someone more knowledgable on that subject will chime in to help you out...
    Using LabVIEW: 7.1.1, 8.5.1 & 2013

  • Automated Report Generation fortnightly...

    Dear SAP Guru's
    We need to generate few Reports automatically and send the output in Excel format to few user's mailbox through job scheduling on fortnightly basis.
    How could we choose the fortnight period in job scheduling and data selection period in Report?
    for ex. Suppose the job is schedule on 1st feb, the report should fetch the data for the period 16th Jan to 31st Jan.
    And the next time when executed on 15the feb it should fetch the data for the period 1st feb to 15th feb.
    Kindly suggest.. how to go ahead with this requirement?
    Thanks in advance...

    Hi Vikash,
    For Data selection period, you need to make your selection screen variant in such a way that the date fields are populated dynamically. i.e. here it is 15 days increment(Fortnightly).
    After entering your values in selection screen, and press save. Now you will be prompted to give a variant name. Goto the date field make it a dynamic .
    Hope this helps you.
    Regards,
    Subbu.

  • AWR report generation  and utilizing effectively

    What are the best practices for generating and utilzing the AWR in oracle for performance tuning ?
    I.e
    Do we need to generate a baseline for comparison during the performance issues ?
    What is the best time and best way to generate baseline AWR ?
    Is there a automated way to compare a baseline report to a report during a performance issue?
    your input is appreciated.

    ggworthy wrote:
    What are the best practices for generating and utilzing the AWR in oracle for performance tuning ?
    I.e
    Do we need to generate a baseline for comparison during the performance issues ?
    What is the best time and best way to generate baseline AWR ?
    Is there a automated way to compare a baseline report to a report during a performance issue?post manual way you compare baseline report during performance issue.

  • Automated Report Generation

    Hey,
    I have a report created which accepts 3 parameters which are now defined as dropdowns. I needs to set up an automated job that passes the oracle report all combinations of these three parameters every night and saves the generated pdf in this case to a specified directory, but I am not quite sure on how to do this, so am I looking for pointers on how to do it and where to start.
    Thanks

    You could set up a dbms_job (unix daemon) to call the report and execute at a given time.
    When you call the report then you can pass the parameters without any problem. (with no user intervention)
    I don't have any example but you should be able to find a lot of them.

  • Incorrect indentation when using on-the-flying report generation and IF statement

    Reproduce steps:
    1. Use teststand version 4.2
    2. Turn ON on-the-fying report option.
    3. Report option -> INclude Step Results->Result Filtering Expression = Exclude Passed/Done/Skipped
    4. My simply code is
    For loop
       If something
          Do something
             If somethingmore
               Call Action and set Record Result = ON
            end if
      End IF
    End loop
    Issue:
        The test report generated for "Call Action" indents every new row. Because it is a long test, this make the test report very difficult to read. If there is a very long test, the test report is  become unreadable.
    Is there a solution for this issue?
    Thanks

    Hi Biet,
    Unfortunately this is a known issue with TestStand, which is documented in the TestStand 4.2.x Known Issues. This occurs in situations where you are using HTML reports with On-The-Fly Reporting and a Result Filtering Expression. To avoid this situation, you can do one of a few things:
    Use a different report format
    Turn off On-The-Fly Reporting
    Not filter the results
    If you must filter results, you can modify the process model slightly to improve the situation. Though this is not a complete workaround, it can help.
    First, configue your Report Options so that you are reporting All
    Results, rather than filtering. Leave On the Fly reporting ON. Next, we
    need to make a modification to your process model. In the process model,
    open the ProcessModelPostResultListEntry sequence. In this sequence,
    select the Process Step Result step, and select the Properties tab. On
    that tab, select the Preconditions category. The text for the
    precondition should be the following by default:
    !Runstate.Root.Locals.ReportOptions.DisableReportGeneration &&
    Runstate.Root.Locals.ReportOptions.UseOnTheFlyReporting
    Now, we want to modify this to be as follows:
    !Runstate.Root.Locals.ReportOptions.DisableReportGeneration &&
    Runstate.Root.Locals.ReportOptions.UseOnTheFlyReporting &&
    Parameters.Result.Status != "Passed" &&
    Parameters.Result.Status != "Done" &&
    Parameters.Result.Status != "Skipped"
    This
    new precondition essentially implements our own filtering. In the
    condition that I have supplied, we will not add entries to the report
    where the status is "Passed", "Done", or "Skipped". (You can add
    additional lines to add additional statuses to filter.) The limitation
    here is that the bug provides incorrect indentation, so the results may still be grouped slightly differently than they would be without the bug.
    I hope this helps!
    John M
    National Instruments
    Applications Engineer

  • Production Reporting + Automated Report Generation

    Hello,
    Does anyone know how to genarate reports automatically by using Production Reporting?
    The source data is in Essbase and the data on updated monthly. We should get the updated data on the reports automatically but I do not know how to do it?
    What tools (HAL, DIM?) and skills (JAVA, SQR) are needed to get data automatically? The creation of a normal report can be made with graphical user interface.
    Br
    Mikko

    You could set up a dbms_job (unix daemon) to call the report and execute at a given time.
    When you call the report then you can pass the parameters without any problem. (with no user intervention)
    I don't have any example but you should be able to find a lot of them.

Maybe you are looking for

  • Animated GIF file Creation from no of JPEG files

    Does anybody know the program to convert a many JPEG files to a single animated gif file.

  • Passing video through the mini (HTPC)

    I currently send video out to my television via HDMI from a receiver. I would like to instead input this video signal to a mac mini and output from the mini to the television (i.e. pass the video signal through the mini on the way to the television).

  • Trouble with UIAlertView

    I have a serious problem with UIAlertView. Basically what I want to do is in a function perform two checks. Both can be negative, both can be positive, there is no direct correlation. If a check is positive then an alert is displayed with two options

  • Error when upload appraisal offline forms on portal

    We have use BAdI HRHAP00_OFFLINE to download and upload appraisal document on portal. The error message occurs when upload appraisal document and we cannot debugging in the BAdI, I think the error raise before BAdI processing. Please see error messag

  • I need to find my bridge collection user files,

    I have backed up my image files to an external drive.  I use Bridge to view and sort images that came with Photoshop CS5.0 i have built some collections and would like these to move with the images on to to my back up drive so i can acess them from b