Skip to main content

Prerequisites

Before you begin:

  • Oracle Database 11g or higher
  • A SpringEdge account with an API key
  • DBA privileges to configure ACL (Access Control List)
  • Oracle Wallet configured for HTTPS (SSL) connections

Direct from Database

No middleware, no application layer — send SMS from PL/SQL

DBMS_SCHEDULER

Schedule SMS sends using Oracle's built-in job scheduler

ACL Secured

Oracle ACL controls which schemas can make outbound HTTP calls

CREATE OR REPLACE PROCEDURE send_sms(
  p_phone   IN VARCHAR2,
  p_message IN VARCHAR2
) AS
  l_url     VARCHAR2(200) :=
    'https://api.springedge.com/v1/sms/send';
  l_api_key VARCHAR2(100) := 'YOUR_API_KEY';
  l_json    VARCHAR2(4000);
  l_req     UTL_HTTP.REQ;
  l_resp    UTL_HTTP.RESP;
  l_body    VARCHAR2(4000);
BEGIN
  -- Build JSON payload
  l_json := '{"to":"' || p_phone || '",'
    || '"sender_id":"SPREDG",'
    || '"message":"' || p_message || '",'
    || '"type":"transactional"}';

  -- Set wallet for HTTPS
  UTL_HTTP.SET_WALLET(
    'file:/oracle/wallet', 'wallet_pwd');

  -- Make HTTP POST request
  l_req := UTL_HTTP.BEGIN_REQUEST(
    l_url, 'POST', 'HTTP/1.1');
  UTL_HTTP.SET_HEADER(l_req,
    'Content-Type', 'application/json');
  UTL_HTTP.SET_HEADER(l_req,
    'Authorization',
    'Bearer ' || l_api_key);
  UTL_HTTP.SET_HEADER(l_req,
    'Content-Length', LENGTH(l_json));
  UTL_HTTP.WRITE_TEXT(l_req, l_json);

  -- Get response
  l_resp := UTL_HTTP.GET_RESPONSE(l_req);
  UTL_HTTP.READ_TEXT(l_resp, l_body);
  UTL_HTTP.END_RESPONSE(l_resp);

  DBMS_OUTPUT.PUT_LINE(l_body);
EXCEPTION
  WHEN OTHERS THEN
    DBMS_OUTPUT.PUT_LINE(SQLERRM);
END;
/

PL/SQL CODE

PL/SQL Stored Procedure

This stored procedure uses UTL_HTTP to make an HTTPS POST request to the SpringEdge API. It accepts a phone number and message as parameters and sends the SMS directly from the database.

Call it from any PL/SQL block, trigger, or scheduled job:

BEGIN
  send_sms('+919876543210',
    'Your order has been shipped.');
END;
/

ACL Configuration:

BEGIN
  DBMS_NETWORK_ACL_ADMIN.CREATE_ACL(
    acl       => 'springedge.xml',
    principal => 'YOUR_SCHEMA',
    is_grant  => TRUE,
    privilege => 'connect');
  DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL(
    acl  => 'springedge.xml',
    host => 'api.springedge.com',
    lower_port => 443);
  COMMIT;
END;
/

Use Cases

Transaction Alerts

Send SMS alerts when financial transactions are posted — payments, refunds, credits, and debits.

Scheduled Reports

Use DBMS_SCHEDULER to send daily/weekly SMS summaries to managers — outstanding balances, overdue invoices, KPI alerts.

Database Triggers

Trigger SMS from INSERT/UPDATE events — e.g., SMS when a new order row is inserted into the orders table.

Monitoring Alerts

Send SMS when tablespace usage exceeds thresholds, long-running queries are detected, or deadlocks occur.