Architecting High-Performance Barcode and QR Code Generation in Oracle APEX

Architecting High-Performance Barcode and QR Code Generation in Oracle APEX In high-throughput enterprise systems—such as warehouse management (WMS), manufacturing execution systems (MES), and logistics platforms—generating barcodes on demand can introduce significant CPU overhead and network latency. When rendering thousands of barcodes in Interactive Grids, processing high-volume PDF print runs, or verifying secure digital assets, developers must design beyond basic PL/SQL implementations.


This architectural guide details advanced, production-grade patterns for optimizing, caching, securing, and rendering barcodes and QR codes using the native APEX_BARCODE package in Oracle APEX.


👉 1. Performance Engineering: Caching & Memory Management

Generating a barcode or QR code requires translating raw text into matrix maps or linear sequences, calculating quiet zones, and compiling the result into a binary (BLOB for PNG) or character (CLOB for SVG) format. Running these calculations dynamically for every row in a multi-user, high-volume environment can result in excessive CPU consumption and LOB memory fragmentation.


👉 What is APEX_BARCODE?

APEX_BARCODE is a native PL/SQL package in Oracle APEX used to dynamically generate barcode and QR code images from database values. Because the generation happens at the database level, the resulting images can be rendered across various components within Oracle APEX, including:


  • Classic and Interactive Reports
  • Interactive Grids
  • Cards Regions
  • Form Pages
  • PDF and printed documents (via APEX Office Print or native PDF printing)
  • HTML Email Templates

Supported Output Formats

The package generates outputs in two primary formats:

  1. PNG (BLOB) : Well-suited for downloadable reports, email attachments, and PDF printing.
  2. SVG (CLOB) : Highly scalable and resolution-independent, making it suitable for responsive web interfaces and dashboards.

👉 Supported Barcode and QR Code Types

The APEX_BARCODE package supports several industry-standard barcode variations:
  • QR Code : A two-dimensional matrix barcode widely used for URLs, contact information, and complex alphanumeric strings.
  • Code 128 : A high-density, alphanumeric linear barcode standard used extensively in logistics, shipping, and inventory management.
  • EAN-8 : A numeric-only barcode standard used internationally for identifying products in retail environments where space is limited.

👉 Generating Multiple Barcodes in a Single Query

The following SQL statement demonstrates how to generate multiple barcode types and formats simultaneously using a single SELECT query on the DUAL table:
1. Example of QR Code for PNG Formate :

SELECT
    apex_barcode.get_qrcode_png(
        p_value            => 'Tech Oracle',
        p_scale            => 1,
        p_quiet            => 1,
        p_foreground_color => '#191715',
        p_background_color => '#fcfbfa'
    ) AS qr_png
FROM dual;
  
2. Example of QR Code for SVG Formate :

SELECT
    apex_barcode.get_qrcode_svg(
        p_value            => 'Tech Oracle',
        p_foreground_color => '#191715',
        p_background_color => '#fcfbfa'
    ) AS qr_svg
FROM dual;
3. Example of EAN-8 for PNG Formate :

SELECT
    apex_barcode.get_ean8_png(
        p_value            => '12345678',
        p_scale            => 1,
        p_foreground_color => '#191715',
        p_background_color => '#fcfbfa'
    ) AS ean8_png
FROM dual;
4. Example of Code 128 for PNG Formate :

SELECT
    apex_barcode.get_code128_png(
        p_value            => 'Tech Oracle',
        p_scale            => 1,
        p_foreground_color => '#191715',
        p_background_color => '#fcfbfa'
    ) AS code128_png
FROM dual;

Parameter Breakdown
  • p_value : The data encoded within the code. Depending on the format, this can accept alphanumeric characters, URLs, or strict numeric strings.
  • p_scale : Defines the scaling factor of the generated image. Adjusting this value helps modify the physical size of the output without degrading image quality.
  • p_quiet : Configures the quiet zone (the border margin surrounding the barcode). This spacing is necessary to help optical scanners identify the boundaries of the code.
  • p_foreground_color & p_background_color : Define the Hex color codes for the barcode elements and background, allowing customization to match application branding or contrast requirements.

👉 Technical Comparison: PNG vs. SVG

Choosing the appropriate output format depends on how and where the barcode is displayed to the user:

Scenario / Use Case Recommended Format Technical Reasoning
Interactive Dashboards SVG Renders inline as vector graphics; maintains sharpness on high-DPI screens.
Responsive Web Layouts SVG Scales dynamically with CSS containment without pixelation.
PDF Export & Reports PNG Offers high compatibility with standard PDF rendering engines.
Email Templates PNG High compatibility across legacy desktop and mobile email clients.
Physical Label Printing PNG Provides predictable pixel dimensions for fixed-size label printers.

📷 Demo Output

About the Author

Name: Md. Rayhan Uddin

Designation: Senior Oracle APEX Developer @ Babuland Ltd.

Published: 24 June, 2026

Previous Post Next Post