When working with enterprise applications, it is often necessary to handle files such as resumes, invoices, reports, or scanned documents. Oracle Forms WebUtil provides a powerful set of utilities that allow developers to integrate client-side functionalities into their Forms applications. One of the most common use cases is enabling users to upload and download files between the client machine and the database or application server.
This guide explains in detail how to use WebUtil in Oracle Forms for file upload and download, with examples, configuration steps, and best practices.
What is WebUtil in Oracle Forms?
WebUtil is an Oracle Forms utility library that bridges the gap between the client machine and Oracle Forms runtime environment. It allows Forms to perform tasks that are otherwise restricted, such as:
- Reading and writing files on the client machine.
- Uploading files from the client to the database.
- Downloading files from the database or server to the client.
- Accessing client-side resources like OLE automation, registry, and clipboard.
For file handling, WebUtil provides built-in packages such as CLIENT_GET_FILE_NAME, CLIENT_IMAGE, and CLIENT_TO_DB/DB_TO_CLIENT.
Steps to Configure WebUtil
Before using WebUtil for file upload and download, you need to configure it in your Oracle Forms environment:
- Install WebUtil: Ensure WebUtil is installed along with Oracle Forms.
- Compile WebUtil Library: Compile the
webutil.pllfile into a.plxand attach it to your form. - Update Formsweb.cfg: Enable WebUtil by setting:
WebUtilArchive=frmwebutil.jar,jacob.jar baseHTMLjinitiator=webutiljpi.htm baseHTMLjpi=webutiljpi.htm - Grant Database Privileges: Run
create_webutil_db.sqlto create required database objects. - Attach WebUtil.pll: In Oracle Forms Builder, attach
webutil.pllto your form so that you can use its built-in functions.
Once WebUtil is configured, you are ready to implement file upload and download functionality.
Uploading Files in Oracle Forms Using WebUtil
Uploading means selecting a file from the client machine and storing it either in the database (BLOB column) or on the application server.
Example: Uploading a File into a Database Table
Suppose you have a table documents defined as:
CREATE TABLE documents ( doc_id NUMBER PRIMARY KEY, doc_name VARCHAR2(200), doc_file BLOB );
You can use WebUtil to let users pick a file and upload it into the database.
PL/SQL Code in Forms Trigger (e.g., WHEN-BUTTON-PRESSED):
DECLARE
v_file_name VARCHAR2(200);
BEGIN
-- Open file dialog for user to select file
v_file_name := WebUtil_File.File_Open_Dialog('Select File to Upload', 'C:\', 'All Files (*.*)|*.*', NULL, 1);
IF v_file_name IS NOT NULL THEN
-- Upload file into database
WebUtil_FileTransfer.Client_To_DB
(
v_file_name,
'INSERT INTO documents (doc_id, doc_name, doc_file) VALUES (documents_seq.NEXTVAL, :control.doc_name, EMPTY_BLOB()) RETURNING doc_file INTO :doc_file'
);
MESSAGE('File uploaded successfully.');
SYNCHRONIZE;
ELSE
MESSAGE('No file selected.');
END IF;
END;
Here, the user chooses a file, and WebUtil stores it into the doc_file BLOB column.
Downloading Files in Oracle Forms Using WebUtil
Downloading allows users to retrieve a file stored in the database or application server and save it on their local machine.
Example: Downloading a File from Database
If a file is stored in the documents table, you can download it like this:
DECLARE
v_save_path VARCHAR2(200);
BEGIN
-- Open save dialog for user
v_save_path := WebUtil_File.File_Save_Dialog('Save File As', 'C:\', NULL, NULL);
IF v_save_path IS NOT NULL THEN
-- Download file from database to client machine
WebUtil_FileTransfer.DB_To_Client
(
'SELECT doc_file FROM documents WHERE doc_id = :control.doc_id',
v_save_path
);
MESSAGE('File downloaded successfully.');
SYNCHRONIZE;
ELSE
MESSAGE('Download cancelled.');
END IF;
END;
This retrieves the document from the database and saves it at the chosen client location.
Uploading and Downloading Files from the Application Server
Apart from database storage, you can also use WebUtil to transfer files between the client machine and the application server file system.
- Client to Server:
WebUtil_FileTransfer.Client_To_AS(v_file_name, '/u01/app/files/' || :control.doc_name); - Server to Client:
WebUtil_FileTransfer.AS_To_Client('/u01/app/files/' || :control.doc_name, v_save_path);
This is useful when files do not need to be stored in the database but must be accessible on the server.
Best Practices for File Upload/Download in Oracle Forms
To ensure smooth file handling, keep these points in mind:
- Validate file size before uploading to avoid performance issues.
- Restrict file types (e.g., only PDFs or images) using the file dialog filters.
- Secure database storage for sensitive files instead of saving them on the server file system.
- Provide clear error handling messages when uploads or downloads fail.
- Optimize BLOB handling by keeping files reasonably small (e.g., under 10–20 MB).
Conclusion
Using WebUtil in Oracle Forms, you can easily extend your application to handle files on the client side. Whether you need to upload files into a database, download reports for users, or exchange files with the application server, WebUtil provides built-in procedures that simplify the process.
By following proper configuration steps and best practices, you can make file management secure, user-friendly, and efficient within your Oracle Forms applications.

