Skip to Main Content

Infrastructure Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Unix loop that calls Oracle PL/SQL code then send email

antobayMar 22 2017 — edited Apr 4 2017

Please can someone help me with a Unix loop that calls Oracle PL/SQL code (below) and when done for each iteration to then mail each row to corresponding e-mail address.

Many thanks

SET HEADING      ON  

SET SERVEROUTPUT ON 

 

SPOOL c:\tony\xxx.csv 

 

DECLARE 

 

   c_delimiter CONSTANT VARCHAR2(1) := ','; 

 

   CURSOR cur_emp IS 

      SELECT empno 

            ,ename 

            ,deptno

  ,email

        FROM scott.emp; 

 

BEGIN 

 

   DBMS_OUTPUT.PUT_LINE('EMPNO, ENAME, DEPTNO'); 

 

   FOR rec_emp IN cur_emp LOOP 

 

      DBMS_OUTPUT.PUT_LINE(rec_emp.empno 

                           || c_delimiter 

                           || rec_emp.ename 

                           || c_delimiter 

                           || rec_emp.deptno);

  --Intentionally commented this out as it is impossible within pl/sql code BUT that is my challenge - to send individual email per row*/

  -- SPOOL OFF  

  --!mailx -s 'XYX1234 screen changes' rec_emp.email < XYZ1234 screen changes.txt 

  

END LOOP; 

  END; 

/    

SPOOL OFF 

EXIT

This post has been answered by Dejan T. on Mar 22 2017
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 19 2017
Added on Mar 22 2017
1 comment
271 views