Execute shell script from plsql trigger


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Execute shell script from plsql trigger
# 1  
Old 06-24-2010
Execute shell script from plsql trigger

Hi,
I have been assigned a job which requires me to send mails from unix(Mailx) upon on certain actions triggered in the database.
On insert/update of a certain field into one of the database tables the shell script present in Unix box responsible to send mail though mailx needs to be triggered so as to send the mails in real time.

Please do assist me in this regard, as i am not able find any such option.

Regards,
Hemanth
# 2  
Old 06-24-2010
# 3  
Old 06-24-2010
Hi Guru,
I have tried using this option and this doesnt seemd to call my sh script in unix.
The script i used with dbms_scheduler is:
Code:
begin
dbms_scheduler.create_program
(
'TPP_SEND_EMAIL',
'EXECUTABLE',
'/Temp/ENV/code/BIL/users/usrbil01/Hemz/sndmailscrpt.ksh',
0,
TRUE,
'Send email to ISU'
);
dbms_output.put_line('SUCCESS');
exception
when others then
dbms_output.put_line('Error: '||SQLERRM);
end;

This script returns success but has not called my script 'sndmailscrpt.ksh' responsible to send email.

Please let me know the possible reason behind this.

Regadrs,
Hemanth

Last edited by pludi; 06-24-2010 at 02:31 AM.. Reason: code tags, please...
# 4  
Old 06-24-2010
Quote:
Originally Posted by hemant.bs11
...
Code:
begin
dbms_scheduler.create_program
(
'TPP_SEND_EMAIL',
'EXECUTABLE',
'/Temp/ENV/code/BIL/users/usrbil01/Hemz/sndmailscrpt.ksh',
0,
TRUE,
'Send email to ISU'
);
dbms_output.put_line('SUCCESS');
exception
when others then
dbms_output.put_line('Error: '||SQLERRM);
end;

This script returns success but has not called my script 'sndmailscrpt.ksh' responsible to send email.

Please let me know the possible reason behind this.

...
The reason is that you have simply created a scheduler program, nothing more. In order to execute the script you'll have to run the corresponding job.

I'd suggest you have a look at Oracle's documentation of the DBMS_SCHEDULER supplied package.

tyler_durden
This User Gave Thanks to durden_tyler For This Post:
# 5  
Old 06-25-2010
Execute shell script from plsql trigger

Hi Tyler,
Thank you for your input.
I have now been able to create a job in this regard and run the same, but this results in an error.
The error seems to be related to OS, but i am not aware as to how to get through this
Job:
begin
dbms_scheduler.create_job
(
job_name =>'TPP_SEND_EMAIL_JOB',
job_type =>'EXECUTABLE',
job_action =>'/Temp/ENV/code/BIL/users/usrbil01/Hemz/sndmailscrpt.ksh',
repeat_interval =>'FREQ=MINUTELY; INTERVAL=30',
enabled =>true,
comments =>'Send Email on ISU update'
);
end;
/

Command to run the job:
exec dbms_scheduler.run_job('TPP_SEND_EMAIL_JOB');

The job is failing with the error:
ORA-27370: job slave failed to launch a job of type EXECUTABLE
ORA-27300: OS system dependent operation:accessing extjob wrapper failed with status: 2
ORA-27301: OS failure message: No such file or directory
ORA-27302: failure occurred at: sjsec 3

Please do assist me getting over:
> Error as above
> Is "repeat_interval" mandatory here, I want to execute this job from within a trigger as and when the trigger is executed without specifying a timeline for its execution(Minutely,hourly etc..).
Is this possible, if not please suggest me a way forward.
I am running out of time for my delivery on this Smilie

Thank you in advance.
Awaiting your reply

Regards,
Hemanth
# 6  
Old 06-25-2010
If you just want to send a mail, why not use the utl_smtp package?
This User Gave Thanks to Ygor For This Post:
# 7  
Old 06-25-2010
Hi,
Firstly, Thank you for the input.
Below are my requirements:
> I have to send mail in html format having dynamic fields like (name,address etc..) which may change from person to person the mail is sent for.
> The template for the mail has to be configrable i.e, it is constant as of now but may be changed in future.

I have also been able to gather a few information about the utl_mail package in 10g which may solve the purpose of sending mail through database, but I am not able to find out if that supports sending email in html format and also support of dynamic data and configurable template.
I see most of this possible in unix, hence lokking at a job from database.
Please do let me know if i can expedite one of these approaches subject to my time lines
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Creating IN list in PLSQL script dynamically by using shell script

Hi all, I have a PLSQL script which has a IN list where it takes some ids as input. For example SELECT * FROM EMPLOYEE WHERE EMPLOYEE_ID IN (comma separated list ) I want to run this quest inside a shell script but I would like to prepare the IN list dynamically where the employee ids... (1 Reply)
Discussion started by: LoneRanger
1 Replies

2. Shell Programming and Scripting

Shell script trigger using http interface

Hi I have created a shell program, which takes a series of parameters as shown in the below code. Its working good from terminal. My program restorejob.sh -g <NAME> -p <Path-to-search> -r <Path-to-restore> Its working fine from bash shell. I want to extend this functionality like... (1 Reply)
Discussion started by: rakeshkumar
1 Replies

3. Shell Programming and Scripting

calling a plsql procedure through shell script

I have a plsql procedure inside a package which is having one IN parameter .I want to call that procedure through a shell script and that IN parameter is a column of a table in the database. So my requirement is that i need to loop all the entries of that IN parameter from the table through shell... (4 Replies)
Discussion started by: rspnf
4 Replies

4. Programming

Executing shell script from PLSQL

Hi All, I have a requirement to mv a file in unix from plsql procedure. for that i have created a java host procedure, a host_command, given all grants as per ORACLE-BASE - Oracle8i Shell Commands From PL/SQL but i am getting an error ""Process err :/bin/sh: mv Not Found"" kindly let me... (1 Reply)
Discussion started by: aryan_styles
1 Replies

5. Shell Programming and Scripting

How to trigger workflow manager through shell script?

I am new to siebel workflow manager. Can anyone help me regarding the shell script which will trigger siebel workflow manager. I want a sample shell script to trigger workflow manager. Thanks in advance. (2 Replies)
Discussion started by: siri_886
2 Replies

6. Programming

running PLSQL scripts through shell script

I am running the following ealth checks on my server there are two databases in my server . MODEL1 and MODEL2 i connect with the first database as sqlplus model1/password Then i exceute a query select x from table (4 Replies)
Discussion started by: asalman.qazi
4 Replies

7. Shell Programming and Scripting

Shell Script to Parse PLSQL code?

Hi All, I am supposed to present the documentation for the PLSQL code (PACKAGES, PROCEDURE, FUNCTIONS) of my application. There are sufficient comments in my code. Has anyone written any Shell Script Utility which can parse the PLSQL code and generate some kind of document ( preferrably HTML not... (2 Replies)
Discussion started by: gauravsachan
2 Replies

8. Programming

UNIX Shell Script to Create a Document of a PLSQL code.

Hi All, I am supposed to present the documentation for the PLSQL code (PACKAGES, PROCEDURE, FUNCTIONS) of my application. There are sufficient comments in my code. Has anyone written any Shell Script Utility which can parse the PLSQL code and generate some kind of document ( preferrably HTML not... (1 Reply)
Discussion started by: gauravsachan
1 Replies

9. UNIX for Dummies Questions & Answers

Can we trigger an shell script on an event

Hi, My program A updates a log called logA. I have a shell script S that is responsible to send emails reading from the log. I want to trigger execution of the script whenever there is an update to the log. Thanks in advance. (8 Replies)
Discussion started by: cv_pan
8 Replies

10. Shell Programming and Scripting

Shell script call from a DB trigger

Has anybody been able to execute a shell script call from a database trigger? If so what are the steps to execute it? Do we have any specific packages in Oracle? Reards, Rahul. (1 Reply)
Discussion started by: rahulrathod
1 Replies
Login or Register to Ask a Question