If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > using DB2v9,How to send email from stored procedure?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-31-09, 07:41
saching saching is offline
Registered User
 
Join Date: Dec 2009
Posts: 15
using DB2v9,How to send email from stored procedure?

How to send email from stored procedure?
Reply With Quote
  #2 (permalink)  
Old 01-01-10, 03:07
przytula_guy przytula_guy is offline
Registered User
 
Join Date: Apr 2006
Location: Belgium
Posts: 1,159
in developers work there is a sample, how to call an external command/program from within a sp. see os_cmd..
__________________
Best Regards, Guy Przytula
Database Software Consultant
DB2 UDB LUW Certified V7-V8-V9-V9.7 DB Admin - Dprop..
Information Server Datastage Certified
http://www.infocura.be
Reply With Quote
  #3 (permalink)  
Old 01-04-10, 02:06
saching saching is offline
Registered User
 
Join Date: Dec 2009
Posts: 15
using DB2v9,How to send email from stored procedure?

Happy New Year

could you please share with me developer work link?

Thanks
Reply With Quote
  #4 (permalink)  
Old 01-04-10, 02:34
przytula_guy przytula_guy is offline
Registered User
 
Join Date: Apr 2006
Location: Belgium
Posts: 1,159
__________________
Best Regards, Guy Przytula
Database Software Consultant
DB2 UDB LUW Certified V7-V8-V9-V9.7 DB Admin - Dprop..
Information Server Datastage Certified
http://www.infocura.be
Reply With Quote
  #5 (permalink)  
Old 01-05-10, 05:18
saching saching is offline
Registered User
 
Join Date: Dec 2009
Posts: 15
================================================== ==========
About DB2 Administration Tools Environment
================================================== ==========
DB2 administration tools level:
Product identifier SQL09013
Level identifier 01040107
Level DB2 v9.1.300.257
Build level s070719
PTF WR21392
================================================== ==========
Java development kit (JDK):
Level IBM Corporation 1.5.0
================================================== ==========

WHile running procedure i am getting following error
========================================
DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL0204N "UTL_SMTP.CONNECTION" is an undefined name. LINE NUMBER=10.
SQLSTATE=42704

SQL0204N "UTL_SMTP.CONNECTION " is an undefined name.
==========================================

CREATE PROCEDURE SSOGDF.send_mail(
IN p_sender VARCHAR(4096),
IN p_recipient VARCHAR(4096),
IN p_subj VARCHAR(4096),
IN p_msg VARCHAR(4096),
IN p_mailhost VARCHAR(4096))
SPECIFIC send_mail
LANGUAGE SQL
BEGIN
DECLARE v_conn UTL_SMTP.CONNECTION;
DECLARE v_crlf VARCHAR(2);
DECLARE v_port INTEGER DEFAULT 25;

SET v_crlf = CHR(13) || CHR(10);
SET v_conn = UTL_SMTP.OPEN_CONNECTION(p_mailhost, v_port, 10);
CALL UTL_SMTP.HELO(v_conn, p_mailhost);
CALL UTL_SMTP.MAIL(v_conn, p_sender);
CALL UTL_SMTP.RCPT(v_conn, p_recipient);
CALL UTL_SMTP.DATA(
v_conn,
'Date: ' || TO_CHAR(SYSDATE, 'Dy, DD Mon YYYY HH24:MIS') || v_crlf ||
'From: ' || p_sender || v_crlf ||
'To: ' || p_recipient || v_crlf ||
'Subject: ' || p_subj || v_crlf ||
p_msg);
CALL UTL_SMTP.QUIT(v_conn);
END@

Please guide me.
Reply With Quote
  #6 (permalink)  
Old 01-05-10, 05:48
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
You didn't create the UTL_SMTP.OPEN_CONNECTION function or the UTL_SMTP.MAIL stored procedures.

In any case, the above approach is bound to be very problematic. You carry connection information from one UDF/stored procedure call to the next - but you don't even know if the UDF/stored procedure will be executed in the same process as the previous call. So if the data type UTL_SMTP.CONNECTION (whatever that is) does not include all the information of the email to be sent, this is shaky at best.

p.s: To really respond to your problem, you should let us know where the UTL_SMTP stuff comes from...
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #7 (permalink)  
Old 01-05-10, 06:14
saching saching is offline
Registered User
 
Join Date: Dec 2009
Posts: 15
UTL_SMTP is a package It's belongs to sysibmadm Schema.but susibmadm schema is not in database.
Reply With Quote
  #8 (permalink)  
Old 01-05-10, 20:31
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Maybe you didn't follow some upgrade procedure at some point? Try running the "db2updv9" utility... If that doesn't help, you may have a DB2 version that doesn't match with your documentation, i.e. those functions are not yet in the version you are running.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #9 (permalink)  
Old 01-07-10, 03:17
dr_te_z dr_te_z is offline
Registered User
 
Join Date: Jan 2009
Location: Zoetermeer, Holland
Posts: 555
Looks complicated..... Why not the KISS approach:
- it is easy (so I am told) to send an email from java
- you can use the java-language for Stored Procedures
- you can call one SP from another SP
- so, why not create one dedicated "send-mail-java" SP and call that when required?
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On