Barcode and QR Code Generation in Oracle APEX
Introduction
In this blog, I explain how I implemented Barcode Generator and QR Code Generator in Oracle APEX 24.2, how data is stored and fetched from database tables, and how barcodes and QR codes are rendered dynamically in reports.
Why Barcode and QR Code Are Needed
-
Unique identification of products
-
Faster scanning compared to manual entry
-
Reduced human errors
-
Easy integration with scanners and mobile devices
-
Useful for inventory, billing, logistics, and asset tracking
Flow
-
Create a Form Page to enter product details
-
Save product data into database tables
-
Display data using Interactive Report / Classic Report
-
Generate Barcode and QR Code dynamically using JavaScript libraries
-
Render the output inside the report region
Tables Used
Examples:
-
BARCODE– stores product details for barcode generation -
QR_CODE– stores product details for QR code generation
Data Fetching Query (Barcode)
Explanation
-
<svg>acts as a placeholder for barcode rendering -
jsbarcode-valueholds the actual barcode data -
jsbarcode-textdisplays readable text below the barcode -
Barcode is rendered later using JavaScript
Data Fetching Query (QR Code)
Explanation
-
<div class="qr-code">acts as a placeholder -
data-valuestores the QR content safely usingAPEX_ESCAPE -
QR code is generated dynamically on page load
Static Application Files Setup
To render barcodes and QR codes, JavaScript libraries must be uploaded.
Upload the following files to Static Application Files:
Page JavaScript File URLs
Add the following in Page → JavaScript → File URLs:
JavaScript Code (Execute when Page Loads)
Output Rendering
After page load:
-
Barcodes are rendered inside
<svg class="barcode"> -
QR Codes are generated inside
<div class="qr-code"> -
Both are displayed properly in the report region
No page refresh or manual trigger is required.
Issues Faced and Fixes
1. Barcode Not Rendering
2. QR Code Not Displaying in Report
APEX_ESCAPE.HTML_ATTRIBUTE() to safely pass values.3. JavaScript Not Executing
Advantages of This Approach
-
No external server dependency
-
Works fully inside Oracle APEX
-
Lightweight and fast rendering
-
Easy to customize barcode format and QR size
-
Suitable for reports, cards, and dashboards
Conclusion
This implementation helped me dynamically generate and display barcodes and QR codes directly from database values without complex plugins or external APIs.
Comments
Post a Comment