Building an AI-Based OCR Solution in Oracle APEX Using Google Vision API
Introduction
Building an AI-Based OCR Solution in Oracle APEX Using Google Vision API

Introduction
While working on one of my Oracle APEX applications, I encountered a common business problem — users were manually entering information from uploaded images such as certificates, labels, and printed documents into the system.
This process was slow, repetitive, and error-prone, especially when users handled multiple records daily. I wanted to automate the text extraction process directly inside Oracle APEX without introducing complex third-party desktop software into the workflow.
After exploring different OCR options, I decided to integrate Google Vision API with Oracle APEX using PL/SQL and REST APIs. The goal was simple:
- Upload an image
- Extract text using AI OCR
- Display the extracted result instantly inside the application
Application Flow
The complete OCR workflow looks like this:

Creating the Upload Interface in Oracle APEX
The first step was building a simple upload interface where users could upload images and trigger OCR processing.
1. File Upload Item
For image uploads, I used the built-in File Browse item available in Oracle APEX.
Page Item
P2_IMAGE_UPLOAD
This allowed users to upload:
- JPG
- PNG
- JPEG
files directly from desktop and mobile devices.
One thing I liked about using the native APEX upload component is that uploaded files are automatically stored temporarily inside:
APEX_APPLICATION_TEMP_FILES
which made the backend processing straightforward.

2. Extract Text Button
Next, I created a button to trigger the OCR process.
Button Name
EXTRACT_TEXT
When the button is clicked:
- The uploaded image is processed
- A PL/SQL process starts
- The REST API request is sent to Google Vision API
- OCR extraction begins
Initially, I tested the process using Dynamic Actions, but later shifted most of the logic into a PL/SQL process to simplify debugging and response handling.
3. OCR Result Display Field
To display the extracted content, I used a Text Area item.
Page Item
P2_DISPLAY_TEXT
Once the OCR process completes, the extracted text is automatically displayed inside this field.

Configuring Google Vision API
Before integrating with Oracle APEX, Google Vision API needs to be configured.
I created a Google Cloud project and enabled the Vision API service.
The setup process was fairly simple.
Step 1 — Create Google Cloud Project
Inside Google Cloud Console:
- Create a new project

Step 2 — Enable Vision API
Navigate to:
APIs & Services → Library
Then enable:
Cloud Vision API

Step 3 — Generate API Key
Under:
Credentials → Create Credentials
generate an API key that will later be used inside the Oracle APEX REST call.

Reading Uploaded Files in Oracle APEX
Once the image is uploaded, Oracle APEX stores the file temporarily inside:
APEX_APPLICATION_TEMP_FILES
The first step in the PL/SQL process was reading the uploaded BLOB file.
SELECT blob_content
INTO l_blob
FROM apex_application_temp_files
WHERE name = :P2_IMAGE_UPLOAD;
This part was straightforward, but during testing I noticed that large image uploads significantly increased processing time.
Converting Image to Base64
Google Vision API accepts images in Base64 format.
So the uploaded BLOB needed to be converted before sending the API request.
l_base64 :=
replace(
replace(
apex_web_service.blob2clobbase64(l_blob),
chr(10),
''
),
chr(13),
''
);
One issue I faced here was line breaks being automatically inserted into the Base64 output. Removing carriage returns and newline characters was necessary to avoid malformed JSON payloads.
This small cleanup step solved several API request failures during testing.
Building the JSON Request Payload
After converting the image, the next step was constructing the JSON payload expected by Google Vision API.
l_request_body :=
'{
"requests":[
{
"image":{
"content":"' || l_base64 || '"
},
"features":[
{
"type":"TEXT_DETECTION"
}
]
}
]
}';
I initially tested multiple OCR detection types, but for my use case, TEXT_DETECTION provided the best balance between speed and accuracy.
Sending REST API Request from Oracle APEX
The REST request was handled using the APEX_WEB_SERVICE package.
l_response := apex_web_service.make_rest_request(
p_url => 'https://vision.googleapis.com/v1/images:annotate?key=YOUR_API_KEY',
p_http_method => 'POST',
p_body => l_request_body
);
This was one of the most interesting parts of the implementation because Oracle APEX handled the external REST integration smoothly without requiring additional middleware.
During testing, I also added proper exception handling to capture API failures, invalid images, and timeout scenarios.
Parsing OCR Response
Google Vision API returns a nested JSON response containing the detected text.
To extract the OCR content, I used JSON_VALUE.
SELECT json_value(
l_response,
'$.responses[0].fullTextAnnotation.text'
)
INTO l_text
FROM dual;
The extracted text was then assigned directly to the page item.
:P2_DISPLAY_TEXT := l_text;
At this stage, the OCR result immediately appeared on the screen after processing.
Final Result
The final solution significantly reduced manual data entry effort inside the application.
Users could now:
- Upload an image
- Click a button
- Extract text instantly using AI OCR
directly within Oracle APEX.
The implementation also demonstrated how easily Oracle APEX can integrate with modern AI services using REST APIs and PL/SQL.
Conclusion
This implementation started as an experiment to reduce manual typing effort in an Oracle APEX application, but it quickly became a practical AI-powered feature with real business value.
What I found most interesting during this project was how effectively Oracle APEX handled:
- File uploads
- REST integrations
- JSON parsing
- Dynamic UI updates
without requiring complex external frameworks.
For developers exploring AI integrations in Oracle APEX, OCR is an excellent starting point because it combines practical business usage with modern AI capabilities.
The same approach can later be extended for:
- Intelligent document processing
- Invoice automation
- Identity verification
- Barcode scanning
- AI-assisted data entry
- Smart validation workflows
As AI services become more accessible through REST APIs, integrating intelligent automation into Oracle APEX applications is becoming much more achievable than before.
메타데이터
- post_id
- a9d5d82a8a55
- slug
- building-an-ai-based-ocr-solution-in-oracle-apex-using-google-vision-api-a9d5d82a8a55
- url
- https://medium.com/@santhosshjagankr/building-an-ai-based-ocr-solution-in-oracle-apex-using-google-vision-api-a9d5d82a8a55
- canonical_url
- https://medium.com/@santhosshjagankr/building-an-ai-based-ocr-solution-in-oracle-apex-using-google-vision-api-a9d5d82a8a55
- author_url
- https://medium.com/@santhosshjagankr
- status
- ok
- fetched_at
- 2026-06-09 15:37:30