database - Insert part of a PL/SQL output into a message body and email it -


i trying create pl/sql program allow me automatically send out emails data picked in output of sql command.

my current output columns are

db_name    sc_name    ro_name    user_name    email_id. 

there 293 rows in output. out of 293... there 11 distinct outputs in the user_name column. example: 1 of distinct outputs in user_name column john. now... every row john... want send email email id mentioned in corresponding email_id row.

how extract information send email based on each of distinct outputs?

*edit*

http://i.imgur.com/0q5paqs.png

if @ image above... want email jmgr@gmail.com first 3 rows ( user_name john). , want email mmgr@gmail.com 4th row (where user_name mike) , forth.

the image above have far.

you want use listagg() function:

select email_id,        listagg(db_name || ' ' || sc_name || ' ' || ro_name, ', ') within group(order db_name, sc_name, ro_name) message  table  group email_id 

Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -