Call now: 252-767-6166  
Oracle Training Oracle Support Development Oracle Apps

 
 Home
 E-mail Us
 Oracle Articles
New Oracle Articles


 Oracle Training
 Oracle Tips

 Oracle Forum
 Class Catalog


 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Analysis
 Design
 Implementation
 Oracle Support


 SQL Tuning
 Security

 Oracle UNIX
 Oracle Linux
 Monitoring
 Remote s
upport
 Remote plans
 Remote
services
 Application Server

 Applications
 Oracle Forms
 Oracle Portal
 App Upgrades
 SQL Server
 Oracle Concepts
 Software Support

 Remote S
upport  
 Development  

 Implementation


 Consulting Staff
 Consulting Prices
 Help Wanted!

 


 Oracle Posters
 Oracle Books

 Oracle Scripts
 Ion
 Excel-DB  

Don Burleson Blog 


 

 

 


 

 

 
 

Using PL/SQL with DB2

Oracle Database Tips by Donald BurlesonSeptember 17,  2015

Question:  I have a staff of trained PL/SQL programmers who need to access a remote IBM DB2 database.  I know all about heterogeneous services, but I've heard that it is possible to execute SQL for DB2 from inside PL/SQL.  Is this true, PL/SQL supports a DB2 interface?  If so, how does one communicate from PL/SQL to DB2?

Answer:  Oracle's PL/SQL procedural language is a very flexible 4th generation ADA-like language and you are correct, you can communicate with DB2 with either heterogeneous services services or the UTL_SMTP package, within PL/SQL.

Communicating with DB2 from inside PL/SQL (which resides inside Oracle) allows for easy data sharing between these different database products, all within the robust programming framework of PL/SQL.

Rampant TechPress author and Oracle ACE Lewis Cunningham has this PL/SQL which communicates with DB2 directly from inside Oracle, using the UTL_SMTP package:

DECLARE

   conn UTL_SMTP.connection;


   reply UTL_SMTP.reply;


   msg VARCHAR2(1024);


   sender VARCHAR2(255) DEFAULT 'demo\@ca.ibm.com';


   recipients VARCHAR2(255);


   subject VARCHAR2(255) DEFAULT 'Quick notification';


   crlf VARCHAR2(2);




BEGIN


     


  crlf := UTL_TCP.CRLF;


  FOR row IN (SELECT first_name, email FROM customer) LOOP


      DBMS_OUTPUT.PUT_LINE('Sending test email to customer ' || row.first_name || '...');


      recipients := row.email;


      msg := 'FROM: ' || sender || crlf ||


                'TO: ' || recipients || crlf ||


                'SUBJECT: ' || subject || crlf ||


                crlf ||


                'Hi ' || row.first_name || ', this is a test notification.';




      UTL_SMTP.OPEN_CONNECTION('smtp_server.ibm.com', 25, conn, 10, reply );


      UTL_SMTP.HELO(conn, 'localhost');


      UTL_SMTP.MAIL(conn, sender);


      UTL_SMTP.RCPT(conn, recipients);


      UTL_SMTP.DATA(conn, msg);


      UTL_SMTP.QUIT(conn);


   END LOOP;


END;


/

 

If you like Oracle tuning, you may enjoy my new book "Oracle Tuning: The Definitive Reference", over 900 pages of BC's favorite tuning tips & scripts. 

You can buy it direct from the publisher for 30%-off and get instant access to the code depot of Oracle tuning scripts.



 

 

��  
 
 
Oracle Training at Sea
 
 
 
 
oracle dba poster
 

 
Follow us on Twitter 
 
Oracle performance tuning software 
 
Oracle Linux poster
 
 
 

 

Burleson is the American Team

Note: This Oracle documentation was created as a support and Oracle training reference for use by our DBA performance tuning consulting professionals.  Feel free to ask questions on our Oracle forum.

Verify experience! Anyone considering using the services of an Oracle support expert should independently investigate their credentials and experience, and not rely on advertisements and self-proclaimed expertise. All legitimate Oracle experts publish their Oracle qualifications.

Errata?  Oracle technology is changing and we strive to update our BC Oracle support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:  

and include the URL for the page.


                    









Burleson Consulting

The Oracle of Database Support

Oracle Performance Tuning

Remote DBA Services


 

Copyright © 1996 -  2020

All rights reserved by Burleson

Oracle ® is the registered trademark of Oracle Corporation.