I have the following query:
SELECT DISTINCT purchase_authorizer_api.get_userid('30', pagl.authorize_id)
FROM purch_authorize_group_line pagl join purchase_authorizer pa
ON pagl.authorize_id = pa.authorize_id
WHERE pagl.authorize_group_id = '30-QA-NUC'
AND pa.notify_user = 'TRUE';
Which gives me the userid's for PO authroizers in that authorization group. I can have several PO authorizers. I need to be able to email all of them.
I'm trying to create an event action in our ERP system that will run the following whenever a PO is released:
BEGIN
command_sys.mail(from_user_name_ => 'IFSAPP',
to_user_name_ => 'youremail@yourdomain.com',
subject_ => 'Test subject',
text_ => 'Test message body');
COMMIT;
END;
I can enter multiple userid's in the to_user_name section but I'm having a hard time figuring out how I can get the results of this query in the to_user_name section?
EDIT: I'm still trying this but I'm not able to get it working:
CREATE PROCEDURE a_proc
AS
cursor get_emails is
SELECT DISTINCT purchase_authorizer_api.get_userid('30', pagl.authorize_id) AS "EMAIL"
FROM purch_authorize_group_line pagl join purchase_authorizer pa
ON pagl.authorize_id = pa.authorize_id
WHERE pagl.authorize_group_id = '30-PM-COM'
AND pa.notify_user = 'TRUE';
result_ VARCHAR2(500);
BEGIN
OPEN get_emails;
FETCH get_emails BULK COLLECT INTO vi_emails;
CLOSE get_emails;
FOR indx IN 1..vi_emails.COUNT LOOP
command_sys.mail(from_user_name_ => 'IFSAPP',
to_user_name_ => result_,
subject_ => 'Test subject',
text_ => 'Test message body');
END LOOP;
END a_proc;
EDIT2:
I've updated to this:
CREATE OR REPLACE PROCEDURE a_proc
is vi_get_emails varchar2(500);
cursor get_emails is
SELECT DISTINCT purchase_authorizer_api.get_userid('30', pagl.authorize_id) AS "EMAIL"
FROM purch_authorize_group_line pagl join purchase_authorizer pa
ON pagl.authorize_id = pa.authorize_id
WHERE pagl.authorize_group_id = '30-PM-COM'
AND pa.notify_user = 'TRUE';
BEGIN
OPEN get_emails;
FETCH get_emails INTO vi_get_emails;
CLOSE get_emails;
FOR rec_ IN get_emails LOOP
command_sys.mail(from_user_name_ => 'IFSAPP',
to_user_name_ => vi_get_emails,
subject_ => 'Test subject',
text_ => 'Test message body');
END LOOP;
END a_proc;
Which is compiling with no errors. However, no emails are going to the users.