Forum Stats

  • 3,851,702 Users
  • 2,264,013 Discussions


Output results to an email/PL SQL

3489453 Member Posts: 1
edited Jun 21, 2017 4:10PM in SQL & PL/SQL

Hi I am trying to output results of the following SQL command to an email, So when it executes the results are sent to me in an Email. How could I do that, I looked at a couple examples but none of it made sense in terms of syntax. Thank you in advance.

SELECT SADDR, SID, Serial#,PADDR, UserName,OSUSER, Status, Logon_Time

FROM v$session

WHERE Status = 'ACTIVE';



  • John Stegeman
    John Stegeman Member Posts: 24,269 Blue Diamond
    edited Jun 21, 2017 1:41PM

    What examples did you look at?

  • Gary_A
    Gary_A Member Posts: 624 Bronze Badge
    edited Jun 21, 2017 4:10PM

    You have not said anything about OS, DB version, etc.

    I have had great luck with Oracle's DEMO_MAIL package. Search for it.

    Beware that in order for Oracle to be able to send email, you may need to get network, firewall and DBA's involved. That is also assuming you are using the latest version of the database. Before 11g, you would not need to setup ACL (access control lists), but those versions are unsupported.

    it may be easiest to just create a scheduled job to output the query results to a file and then have a file watcher use the client email program to send the file.

    Either way, there may be a lot of work involved.

This discussion has been closed.