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

 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
 Oracle Support

 SQL Tuning

 Oracle UNIX
 Oracle Linux
 Remote s
 Remote plans
 Application Server

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

 Remote S


 Consulting Staff
 Consulting Prices
 Help Wanted!


 Oracle Posters
 Oracle Books

 Oracle Scripts

Don Burleson Blog 







How to create a word document from Oracle

Oracle Database Tips by Donald BurlesonDecember 27, 2015

Question: I want to create a Microsoft Word doc from data within an Oracle table.  How do I run SQL to extract Oracle rows and format them as a Word document?

Answer:  Inside MS Word there is a mail merge utility that can gather data extracted from Oracle via ODBC into a Word doc, but this cannot be scripted. 

Creating a Word doc from Oracle table rows

Within Oracle, you can generate a word doc from Oracle table data you must install and configure Oracle COM Automation Feature package which is included as part of Oracle installation.

The Oracle documentation has a Oracle COM MS-Word example for creating a Microsoft Word document containing the names of employees in the database.

This link shows a sample script to create an MS-Word document from Oracle table data.

Also, this page shows detailed steps for storing a Word doc in Oracle:

1 - Create a table to hold the MS-Word document:


   name VARCHAR2(200) NOT NULL,
   doc  BLOB          NOT NULL

2) Create a directory object which stores all your Word docs:


3) Create a procedure to store the Word doc in Oracle:

CREATE OR REPLACE PROCEDURE load_file_to_my_docs (p_file_name IN
v_bfile BFILE;
v_blob BLOB;
INSERT INTO my_docs (name, doc)
VALUES ( p_file_name, empty_blob())
RETURN doc INTO v_blob;
v_bfile := BFILENAME('documents', p_file_name);
Dbms_Lob.Fileopen(v_bfile, Dbms_Lob.File_Readonly);
Dbms_Lob.Loadfromfile(v_blob, v_bfile, Dbms_Lob.Getlength(v_bfile));

4)Execute the above procedure to store the Word doc in Oracle:


If you like Oracle tuning, you might enjoy my book "Oracle Tuning: The Definitive Reference", with 950 pages of tuning tips and 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.