<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Hassan Ali</title>
    <description>The latest articles on DEV Community by Hassan Ali (@hassan_ali_1b53672707d14b).</description>
    <link>https://dev.to/hassan_ali_1b53672707d14b</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4277934%2F414c0951-037f-4838-9ab4-d3e1474c9d00.jpg</url>
      <title>DEV Community: Hassan Ali</title>
      <link>https://dev.to/hassan_ali_1b53672707d14b</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hassan_ali_1b53672707d14b"/>
    <language>en</language>
    <item>
      <title>Building a Procurement and Invoice Control Platform with Oracle APEX and ORDS</title>
      <dc:creator>Hassan Ali</dc:creator>
      <pubDate>Wed, 02 Dec 2026 09:53:41 +0000</pubDate>
      <link>https://dev.to/hassan_ali_1b53672707d14b/building-a-procurement-and-invoice-control-platform-with-oracle-apex-and-ords-d69</link>
      <guid>https://dev.to/hassan_ali_1b53672707d14b/building-a-procurement-and-invoice-control-platform-with-oracle-apex-and-ords-d69</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;I built a procurement and invoice control application to explore how Oracle APEX could be used to manage a business workflow beyond standard forms and reports.&lt;/p&gt;

&lt;p&gt;The application manages purchase requests, suppliers, departmental budgets, approvals and invoices. Two requirements shaped the implementation: procurement approvals must stay within the available departmental budget, and invoice amounts must not exceed the approved request value.&lt;/p&gt;

&lt;p&gt;I developed and tested the application in a hosted Oracle APEX environment using fictional procurement data.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Technology Stack
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Technology&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Oracle APEX&lt;/td&gt;
&lt;td&gt;Application interface, forms and reports&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Oracle Database&lt;/td&gt;
&lt;td&gt;Relational data storage&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Oracle SQL&lt;/td&gt;
&lt;td&gt;Queries, views and financial calculations&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Oracle PL/SQL&lt;/td&gt;
&lt;td&gt;Business logic and transaction validation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Oracle REST Data Services (ORDS)&lt;/td&gt;
&lt;td&gt;REST API development&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;OAuth 2.0&lt;/td&gt;
&lt;td&gt;Protected API access&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The project did not require a separate frontend framework or a locally hosted database.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Application Architecture
&lt;/h2&gt;

&lt;p&gt;APEX handles the application interface. SQL and PL/SQL handle calculations, data retrieval and business rules, while Oracle Database stores the procurement records.&lt;/p&gt;

&lt;p&gt;ORDS provides a separate interface for external integrations.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Application Users
        |
    Oracle APEX
        |
    SQL / PL/SQL
        |
   Oracle Database
        |
       ORDS
        |
 Protected REST API
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Authenticated external applications can retrieve departmental budget information through the REST endpoint without connecting directly to the database.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Database Design
&lt;/h2&gt;

&lt;p&gt;I separated the procurement data into related tables to manage departments, suppliers, budgets, requests and invoices independently.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Database object&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;PP_DEPARTMENTS&lt;/td&gt;
&lt;td&gt;Department information&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PP_SUPPLIERS&lt;/td&gt;
&lt;td&gt;Supplier records&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PP_BUDGETS&lt;/td&gt;
&lt;td&gt;Departmental budget allocations&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PP_REQUESTS&lt;/td&gt;
&lt;td&gt;Procurement requests&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PP_REQUEST_LINES&lt;/td&gt;
&lt;td&gt;Individual request items&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PP_INVOICES&lt;/td&gt;
&lt;td&gt;Supplier invoices&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PP_REQUEST_SUMMARY_V&lt;/td&gt;
&lt;td&gt;Consolidated procurement reporting&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The database uses primary keys, foreign keys, unique constraints and check constraints to maintain data integrity.&lt;/p&gt;

&lt;p&gt;Since the application uses Bahraini dinars (BHD), monetary values are stored with three decimal places.&lt;/p&gt;

&lt;p&gt;For example, departmental budget allocations use the following data type:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="n"&gt;allocated_amount&lt;/span&gt; &lt;span class="no"&gt;NUMBER&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;14&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="kc"&gt;NULL&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The budget table also prevents negative allocations through a check constraint.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;CONSTRAINT&lt;/span&gt; &lt;span class="n"&gt;pp_budget_amount_ck&lt;/span&gt;
&lt;span class="k"&gt;CHECK&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;allocated_amount&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These restrictions prevent invalid records from being stored, regardless of whether the data is entered through an APEX form or directly through SQL.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Building the Application with Oracle APEX
&lt;/h2&gt;

&lt;p&gt;I used Oracle APEX to develop the forms, reports, navigation and dashboard.&lt;/p&gt;

&lt;p&gt;The exported application contains:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;34 pages&lt;/li&gt;
&lt;li&gt;83 regions&lt;/li&gt;
&lt;li&gt;39 processes&lt;/li&gt;
&lt;li&gt;58 buttons&lt;/li&gt;
&lt;li&gt;13 dynamic actions&lt;/li&gt;
&lt;li&gt;3 authorization schemes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These figures include supporting pages and components generated during application development.&lt;/p&gt;

&lt;p&gt;The application covers department and supplier management, budget allocation, procurement requests, invoices, financial reporting and status auditing.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fwtjgil4z8yq83l6yuta9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fwtjgil4z8yq83l6yuta9.png" alt="Oracle APEX procurement dashboard displaying financial summaries and request statuses" width="800" height="451"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Figure 1. Procurement and invoice control dashboard developed using Oracle APEX.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;APEX handled much of the interface development. I used SQL and PL/SQL for the financial calculations and business rules that required custom logic.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Procurement Request Lifecycle
&lt;/h2&gt;

&lt;p&gt;Each procurement request follows a defined approval workflow.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;       DRAFT
         |
         v
     SUBMITTED
      /     \
     v       v
 APPROVED  REJECTED
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The database model also supports a cancelled status.&lt;/p&gt;

&lt;p&gt;Users can manage procurement items while a request is in draft. Once submitted, database triggers restrict modifications to the request details and associated items.&lt;/p&gt;

&lt;p&gt;Authorized administrators can then approve or reject submitted requests.&lt;/p&gt;

&lt;p&gt;To test the modification restriction, I attempted to update the items of a submitted request through SQL. The database rejected the operation, confirming that the restriction was enforced outside the APEX interface as well.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Master-Detail Forms and Request Calculations
&lt;/h2&gt;

&lt;p&gt;A procurement request can contain several items, each with a quantity and unit price.&lt;/p&gt;

&lt;p&gt;I implemented a master-detail relationship between procurement requests and their associated request lines.&lt;/p&gt;

&lt;p&gt;The individual line amount is calculated as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Line Total = Quantity × Unit Price
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The request total is calculated from its associated line items.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="no"&gt;NVL&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="nb"&gt;SUM&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;ROUND&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;quantity&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;unit_price&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;total_bhd&lt;/span&gt;
&lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;pp_request_lines&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;request_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="no"&gt;P9_REQUEST_ID&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Calculating the total from the underlying records avoids storing a separate header amount that could become inconsistent when request items are modified.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fcs4qgoc2zpnwn2ikwkcx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fcs4qgoc2zpnwn2ikwkcx.png" alt="Procurement request form displaying individual request items and calculated financial totals in BHD" width="720" height="1088"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Figure 2. Procurement request interface with individual items and calculated financial totals.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Users can review the request amount before submitting it for approval.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. Implementing Budget Validation
&lt;/h2&gt;

&lt;p&gt;The approval process checks whether sufficient departmental budget remains before approving a procurement request.&lt;/p&gt;

&lt;p&gt;The available budget is calculated as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Available Budget =
Allocated Budget - Approved Commitments
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The approval process locks the relevant request and budget records before calculating the available amount. I included row locking to reduce the risk of conflicting financial updates during approval.&lt;/p&gt;

&lt;p&gt;For the first negative test, I attempted to approve a procurement request worth BHD 6,060 against a departmental budget of BHD 5,000.&lt;/p&gt;

&lt;p&gt;Oracle returned the application-defined error ORA-20023 and prevented the approval.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fy93fa6nyij6bzfpruowi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fy93fa6nyij6bzfpruowi.png" alt="Oracle APEX error ORA-20023 blocking a BHD 6060 procurement request against a BHD 5000 budget" width="720" height="1150"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Figure 3. Procurement approval blocked because the request amount exceeds the available departmental budget.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;A separate procurement request worth BHD 1,300 was successfully approved.&lt;/p&gt;

&lt;p&gt;The application records status changes in an audit history containing the previous status, new status, responsible user and date.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F2scjimr1pn1a4c9a6cfi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F2scjimr1pn1a4c9a6cfi.png" alt="Procurement request status history showing approval transitions and audit records" width="720" height="1150"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Figure 4. Procurement request approval and recorded status transition history.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The audit history provides a record of how each request progressed through the approval process.&lt;/p&gt;

&lt;h2&gt;
  
  
  8. Invoice Control
&lt;/h2&gt;

&lt;p&gt;The invoice component applies several database-level restrictions after a procurement request has been approved.&lt;/p&gt;

&lt;p&gt;An invoice must satisfy the following conditions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Its associated procurement request must be approved.&lt;/li&gt;
&lt;li&gt;The supplier must match the supplier assigned to the request.&lt;/li&gt;
&lt;li&gt;The invoice amount must be positive.&lt;/li&gt;
&lt;li&gt;The supplier invoice number must not be duplicated.&lt;/li&gt;
&lt;li&gt;The invoice amount must not exceed the approved request value.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The current implementation also permits only one invoice per procurement request.&lt;/p&gt;

&lt;h3&gt;
  
  
  Preventing duplicate invoices
&lt;/h3&gt;

&lt;p&gt;A unique constraint prevents multiple invoices from being associated with the same procurement request.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;CONSTRAINT&lt;/span&gt; &lt;span class="n"&gt;pp_invoice_request_uq&lt;/span&gt;
&lt;span class="k"&gt;UNIQUE&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A separate unique index prevents the same supplier invoice number from being recorded more than once.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="k"&gt;UNIQUE&lt;/span&gt; &lt;span class="k"&gt;INDEX&lt;/span&gt; &lt;span class="n"&gt;pp_invoice_supplier_number_uq&lt;/span&gt;
&lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;pp_invoices&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;supplier_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nb"&gt;UPPER&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;TRIM&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;invoice_number&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Using &lt;code&gt;UPPER&lt;/code&gt; and &lt;code&gt;TRIM&lt;/code&gt; prevents differences in capitalization and surrounding spaces from bypassing the duplicate invoice restriction.&lt;/p&gt;

&lt;p&gt;During testing, an attempt to create a duplicate invoice was rejected by the database.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fzpbig93fqgu6gu068lt8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fzpbig93fqgu6gu068lt8.png" alt="Oracle Database uniqueness constraint preventing duplicate invoice creation" width="720" height="525"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Figure 5. Duplicate invoice operation rejected by an Oracle Database uniqueness constraint.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Validating invoice amounts
&lt;/h3&gt;

&lt;p&gt;I implemented the invoice amount restriction through a PL/SQL database trigger.&lt;/p&gt;

&lt;p&gt;The following excerpt shows the amount validation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;IF&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="no"&gt;NEW&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;amount_bhd&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;l_total&lt;/span&gt; &lt;span class="k"&gt;THEN&lt;/span&gt;
    &lt;span class="nf"&gt;raise_application_error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;20032&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s1"&gt;'Invoice amount exceeds the approved request total.'&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;END&lt;/span&gt; &lt;span class="k"&gt;IF&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To test this restriction, I attempted to record an invoice worth BHD 1,400 against a procurement request approved for BHD 1,300.&lt;/p&gt;

&lt;p&gt;Oracle returned ORA-20032 and prevented the invoice from being recorded.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fygx3znxjbk0or4qqktmo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fygx3znxjbk0or4qqktmo.png" alt="Oracle error ORA-20032 rejecting a BHD 1400 invoice against an approved BHD 1300 procurement request" width="720" height="525"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Figure 6. Database trigger preventing an invoice from exceeding the approved procurement amount.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Because the validation is implemented in a database trigger, it also applies to invoice insert and update operations performed outside the APEX invoice form.&lt;/p&gt;

&lt;h2&gt;
  
  
  9. Authorization and Access Control
&lt;/h2&gt;

&lt;p&gt;I used Oracle APEX authorization schemes to restrict application operations according to user permissions.&lt;/p&gt;

&lt;p&gt;The application distinguishes between three access levels:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Role&lt;/th&gt;
&lt;th&gt;Responsibility&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Reader&lt;/td&gt;
&lt;td&gt;View permitted dashboards and reports&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Contributor&lt;/td&gt;
&lt;td&gt;Create and manage permitted records&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Administrator&lt;/td&gt;
&lt;td&gt;Perform administrative operations and procurement approvals&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Contribution Rights protect record modification operations. Administration Rights protect administrative functions and approval processing.&lt;/p&gt;

&lt;p&gt;I also configured server-side conditions for operations such as creating, saving and deleting records.&lt;/p&gt;

&lt;p&gt;During manual testing, the Reader role could access the permitted dashboard and reports but could not access protected invoice forms or administrative functions.&lt;/p&gt;

&lt;p&gt;One distinction worth understanding when developing APEX applications is the difference between hiding a component and authorizing an operation.&lt;/p&gt;

&lt;p&gt;Hiding a button changes what the user sees. Protecting the underlying server-side process determines whether the user is permitted to execute the operation.&lt;/p&gt;

&lt;p&gt;Both need to be considered when implementing application access controls.&lt;/p&gt;

&lt;h2&gt;
  
  
  10. Financial Reporting
&lt;/h2&gt;

&lt;p&gt;The dashboard retrieves procurement and financial information directly from Oracle Database.&lt;/p&gt;

&lt;p&gt;The reporting components cover request statuses, departmental budget allocations, approved commitments, remaining budgets, invoice counts and invoiced amounts.&lt;/p&gt;

&lt;p&gt;SQL queries and database views calculate these values from the stored records.&lt;/p&gt;

&lt;p&gt;For example, invoice counts and financial totals can be retrieved using:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt;
    &lt;span class="nb"&gt;COUNT&lt;/span&gt;&lt;span class="cm"&gt;(*) AS invoice_count,
    NVL(SUM(amount_bhd), 0) AS total_invoiced
FROM pp_invoices;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At the time of testing, the application contained two invoices totaling BHD 1,380.&lt;/p&gt;

&lt;p&gt;Calculating these values directly from the transaction records removes the need to maintain separate financial summaries manually.&lt;/p&gt;

&lt;h2&gt;
  
  
  11. REST API Integration with Oracle REST Data Services
&lt;/h2&gt;

&lt;p&gt;I configured ORDS to make departmental budget information available to external applications through a GET endpoint.&lt;/p&gt;

&lt;p&gt;Access to the endpoint is restricted through an ORDS privilege and role.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Configuration&lt;/th&gt;
&lt;th&gt;Value&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;HTTP method&lt;/td&gt;
&lt;td&gt;GET&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Privilege&lt;/td&gt;
&lt;td&gt;procurement.read&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Role&lt;/td&gt;
&lt;td&gt;procurement.reader&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Authentication&lt;/td&gt;
&lt;td&gt;OAuth 2.0&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fvv2c15zpnkeaext88q3a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fvv2c15zpnkeaext88q3a.png" alt="Oracle REST Data Services GET handler configuration and departmental budget SQL query results" width="800" height="516"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Figure 7. ORDS GET handler configuration and departmental budget query results.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The authentication and data retrieval process follows this sequence:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;External Client
      |
OAuth 2.0 Authentication
      |
Access Token
      |
Protected ORDS Endpoint
      |
Departmental Budget Information
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After obtaining an access token, I sent an authenticated request to the endpoint.&lt;/p&gt;

&lt;p&gt;The API returned an HTTP 200 response containing the expected departmental budget information.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Department&lt;/th&gt;
&lt;th&gt;Allocated&lt;/th&gt;
&lt;th&gt;Approved&lt;/th&gt;
&lt;th&gt;Available&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;IT&lt;/td&gt;
&lt;td&gt;10,000.000&lt;/td&gt;
&lt;td&gt;1,380.000&lt;/td&gt;
&lt;td&gt;8,620.000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Operations&lt;/td&gt;
&lt;td&gt;5,000.000&lt;/td&gt;
&lt;td&gt;0.000&lt;/td&gt;
&lt;td&gt;5,000.000&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;All amounts are in BHD.&lt;/p&gt;

&lt;p&gt;I also attempted to access the endpoint without authentication. The request was denied.&lt;/p&gt;

&lt;p&gt;ORDS allows external applications to retrieve selected financial information through HTTP requests without requiring direct access to the database.&lt;/p&gt;

&lt;h2&gt;
  
  
  12. Functional Testing
&lt;/h2&gt;

&lt;p&gt;I tested valid and invalid procurement operations, including attempts to bypass the application's financial restrictions.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Test&lt;/th&gt;
&lt;th&gt;Observed result&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Modify submitted request items&lt;/td&gt;
&lt;td&gt;Blocked&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Approve a valid BHD 1,300 request&lt;/td&gt;
&lt;td&gt;Successful&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Approve BHD 6,060 against BHD 5,000 budget&lt;/td&gt;
&lt;td&gt;ORA-20023&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Reject a submitted procurement request&lt;/td&gt;
&lt;td&gt;Successful&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Record request status changes&lt;/td&gt;
&lt;td&gt;Successful&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Create a duplicate invoice for a request&lt;/td&gt;
&lt;td&gt;Blocked&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Reuse a supplier invoice number&lt;/td&gt;
&lt;td&gt;Blocked&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Invoice BHD 1,400 against BHD 1,300 approval&lt;/td&gt;
&lt;td&gt;ORA-20032&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Calculate recorded invoice totals&lt;/td&gt;
&lt;td&gt;BHD 1,380&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Restrict Reader access&lt;/td&gt;
&lt;td&gt;Passed manual checks&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Access ORDS endpoint without authentication&lt;/td&gt;
&lt;td&gt;Denied&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Access ORDS endpoint with OAuth token&lt;/td&gt;
&lt;td&gt;HTTP 200&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The negative tests were particularly useful. A working form alone would not establish whether the application prevents an unauthorized or financially invalid transaction.&lt;/p&gt;

&lt;p&gt;These tests were conducted in the development environment using fictional procurement records.&lt;/p&gt;

&lt;h2&gt;
  
  
  13. What I Learned
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Database design matters in low-code development
&lt;/h3&gt;

&lt;p&gt;APEX reduced the amount of frontend code required, but the relationships between database tables still determined how procurement requests, budgets and invoices could be managed.&lt;/p&gt;

&lt;p&gt;Calculating request totals from individual items was one example of how database design affected the application.&lt;/p&gt;

&lt;h3&gt;
  
  
  Database constraints and PL/SQL triggers serve different purposes
&lt;/h3&gt;

&lt;p&gt;Unique constraints prevented duplicate records, while PL/SQL triggers handled rules that depended on information from related tables.&lt;/p&gt;

&lt;p&gt;The invoice amount restriction required checking the approved request value before accepting an invoice. A simple column constraint would not have been sufficient for that requirement.&lt;/p&gt;

&lt;h3&gt;
  
  
  Authorization needs to cover application processes
&lt;/h3&gt;

&lt;p&gt;Configuring authorization schemes for visible components is useful, but the processes responsible for modifying records need their own protection.&lt;/p&gt;

&lt;p&gt;Testing the Reader role helped me examine these restrictions from the perspective of a user without administrative permissions.&lt;/p&gt;

&lt;h3&gt;
  
  
  ORDS extends the application beyond its interface
&lt;/h3&gt;

&lt;p&gt;Configuring the protected budget endpoint gave me practical experience with REST handlers, privileges, roles and OAuth authentication.&lt;/p&gt;

&lt;p&gt;The same departmental budget information used within the APEX application could also be retrieved by an authenticated external client.&lt;/p&gt;

&lt;h2&gt;
  
  
  14. Current Limitations and Future Development
&lt;/h2&gt;

&lt;p&gt;The application is a learning prototype, not a production procurement system.&lt;/p&gt;

&lt;p&gt;The current implementation permits one invoice per request. Partial invoicing and multiple invoices against a single request are not supported.&lt;/p&gt;

&lt;p&gt;Although row locking is present in the approval process, I did not perform concurrent load testing.&lt;/p&gt;

&lt;p&gt;Budget approval and status transition authorization are enforced through the APEX approval processes. The current implementation does not prevent a database schema owner from directly modifying a request's status.&lt;/p&gt;

&lt;p&gt;The application also does not implement department-level row isolation, a dedicated finance role or separation between requesters and approvers.&lt;/p&gt;

&lt;p&gt;The audit history records request status changes rather than every modification to the underlying records.&lt;/p&gt;

&lt;p&gt;Some extensions I would consider for a future version are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Introduce multi-stage procurement approvals.&lt;/li&gt;
&lt;li&gt;Restrict data access according to departmental membership.&lt;/li&gt;
&lt;li&gt;Generate purchase orders from approved requests.&lt;/li&gt;
&lt;li&gt;Support partial invoices and multiple invoices per request.&lt;/li&gt;
&lt;li&gt;Track supplier performance.&lt;/li&gt;
&lt;li&gt;Send notifications when departmental budget thresholds are reached.&lt;/li&gt;
&lt;li&gt;Process and store invoice documents.&lt;/li&gt;
&lt;li&gt;Integrate procurement records with external ERP systems.&lt;/li&gt;
&lt;li&gt;Explore Oracle AI capabilities for expenditure forecasting.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These features are outside the current implementation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;This project gave me practical experience developing a database-backed business application using Oracle APEX, SQL, PL/SQL and ORDS.&lt;/p&gt;

&lt;p&gt;The completed prototype manages procurement requests, departmental budgets, approval processing, invoice validation, financial reporting and authenticated API access.&lt;/p&gt;

&lt;p&gt;The most useful part of the project was implementing and testing the financial restrictions. APEX provided the interface, while Oracle Database and PL/SQL handled the rules governing which transactions could be accepted.&lt;/p&gt;

&lt;p&gt;In future articles, I plan to examine the individual implementations in more detail, particularly database design, financial validation, authorization and ORDS integration.&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://apex.oracle.com/" rel="noopener noreferrer"&gt;Oracle APEX&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.oracle.com/en/database/oracle/apex/" rel="noopener noreferrer"&gt;Oracle APEX Documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.oracle.com/en/database/oracle/oracle-database/" rel="noopener noreferrer"&gt;Oracle Database Documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.oracle.com/en/database/oracle/oracle-rest-data-services/" rel="noopener noreferrer"&gt;Oracle REST Data Services Documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://ace.oracle.com/" rel="noopener noreferrer"&gt;Oracle ACE Program&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;Author:&lt;/strong&gt; Hasan Rajab&lt;/p&gt;

&lt;p&gt;Oracle ACE Apprentice | Oracle Cloud Infrastructure DevOps Professional&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Project completion date:&lt;/strong&gt; November 30, 2026&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Publication date:&lt;/strong&gt; December 2, 2026&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This project was developed for educational purposes using fictional procurement data. AI-assisted guidance was used during development and documentation, with implementation and testing conducted in my Oracle APEX workspace.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>oracle</category>
      <category>database</category>
      <category>lowcode</category>
    </item>
  </channel>
</rss>
