Email The Output of A Concurrent Program As Attachment
Email The Output of A Concurrent Program As Attachment
Attachment
Author
prudhvi
Name:
E-mail: [email protected]
This article illustrates the steps to be followed to Email a concurrent program’s output.
1) Write a procedure that will submit the concurrent program whose output has to be sent
as an Email and once the program completes, send the output as Email using
UTL_MAIL.send_attach_varchar2.
2) Register this procedure as a concurrent program so that this program can be run from
Note#1: Please try procedure only if your database version is 10g or above. UTM_MAIL
package has been introduced only in 10g and if you are on 9i then try using UTL_SMTP
package.
Note#2: This process requires your application server and database server to be on the
Reason: concurrent program output and log files are created on the application node where
as UTL_MAIL package runs on the database node. If your applications is installed on multi
node then use shell script to mail the output instead of database procedure.
This article illustrates the steps to be followed to Email a concurrent program’s output.
1) Write a procedure that will submit the concurrent program whose output has to be sent
as an Email and once the program completes, send the output as Email using
UTL_MAIL.send_attach_varchar2.
2) Register this procedure as a concurrent program so that this program can be run from
1) Write the below procedure which submits the desired concurrent program and waits
until it completes and then sends the output of that program to the specified Email address
( errbuf VARCHAR2,
retode NUMBER,
p_concurrent_program_name VARCHAR2,
p_parameter1 NUMBER
IS
/*Variable declaration*/
fhandle UTL_FILE.file_type;
v_request_status BOOLEAN;
v_application_id NUMBER;
v_concurrent_program_id NUMBER;
BEGIN
BEGIN
/* Get Concurrent_program_id of the desired program and application_id */
FROM fnd_concurrent_programs_tl
SELECT concurrent_program_name
INTO v_conc_prog_short_name
FROM fnd_concurrent_programs
SELECT application_short_name
INTO v_conc_prog_appl_short_name
FROM fnd_application
EXCEPTION
END;
v_request_id:= fnd_request.submit_request
(v_conc_prog_appl_short_name,
v_conc_prog_short_name,
NULL, --Description
p_parameter1
);
COMMIT;
max_wait => 0,
);
v_dev_phase := NULL;
v_dev_status := NULL;
END IF;
SELECT outfile_name
INTO v_output_file_path
FROM fnd_concurrent_requests
WHERE request_id = v_request_id;
ELSE
END IF;
LOOP
BEGIN
EXCEPTION
EXIT;
END;
END LOOP;
UTL_FILE.fclose (fhandle);
UTL_MAIL.send_attach_varchar2
);
END;
Define Executable:
Define Concurrent program with 2 parameters: Concurrent Program Name and
Program short Name.
Assign this concurrent program to the desired responsibility.
For a more detailed explanation on how to register a concurrent program refer to the below article:
http://www.erpschools.com/Apps/oracle-applications/articles/Sysadmin-and-
AOL/Concurrent-Program-Registration-and-add-it-to-request-group/index.aspx
When this registered concurrent program is run, this program in turn submits the desired concurrent
Note: The above procedure works only if the output file generated (which sits on the Application server)
is accessible to the database server. If the output file is not accessible, use shell script instead of pl/sql
procedure and call mailx or uuencode to email the output. The shell script will work because the
execution of the shell script and the output file will both be on the application server.
srinivas Commented
Hi,
Please check the UTL_MAIL Package is there or not in your database.If it is there then
please check the procedure name and parameters.
For UTL_MAIL package there is also a setup that need to done on init.ora file. Ask your DBA
to set SMTP server in init.ora file.
Thanks
Prudhvi
I have come up with an alternative approach that allows me to email concurrent request
outputs from workflow. Thsi way I can i.e. create a quote and email it automatically to a
client upon approval.
I published the details on http://piotrbelter.blogspot.com
Commented
Hi Priya,
In oracle 10g oracle has provided the script fiels for the UTL_MAIL package.
Thanks
Vijay Gurme
niita
commented on 11/7/2009 12:40:48 AM
Getting below Error while compiling the Procedure.
PLS-00201: identifier 'UTL_MAIL.SEND_ATTACH_VARCHAR2' must be declared
Commented
Hi Niita,
In oracle 10g oracle has provided the script fiels for the UTL_MAIL package.
Vijay Gurme
If you don't have UTL_MAIL package in your database use UTL_SMTP package.
Prudhvi
Commented
I have compile the UTL_MAIL package inthe database. now i am trying to execute the script
provided in this article.
While executing the script i am getting the error as below
ORA-29261: bad argument.
Please suggest...
Thanks
Vijay
Commented
How many parameters does your concurrent program have? Is it Just One? If not you need
to modify the procedure according to the number parameters your concurrent program
have. Please let me know if you have any questions.
Thanks
Prudhvi
Hi Prudhvi,
Can we send the log file of particular request as an attachment through the alert...is that
possible to achieve through alerts?
Please guide me on this...If it is possible then kindly detail me about the steps need to be
followed...
thanks in advance.
Preeti
Hi Prudhvi,
Very gud articals
Thank u
Hari
krishna
reddy commented on 3/26/2010 3:36:25 AM
I need a procedure which will redirect the oracle sql query output to an CLOB/VARCHAR2
VARIABLE . This output i want to attach to the Email using Utl_mail. (Query may fetch more
than 4000records , 4 columns)
I dont want to use UTL_FILE concept i.e to output the query result to a file and then to
attach the file.
Your suggestion/help is more appreciated.
Thanks,
Hi,
It is very good artical.keep it up.
Regards,
Chowri
Hi,
I was told by my DBA, that the conc output files are stored in the following location in our
server.D:\oracle\mdmdev\inst\apps\mdmdev_bsgmdm3\logs\appl\conc\out.
Thanks,
srikanth