0% found this document useful (0 votes)
110 views

Oracle Database Sms Gateway

This document provides a code example for sending SMS messages from an Oracle database through a third-party SMS gateway web service portal. The code declares HTTP request and response objects and constructs a URL to call the SMS gateway API, passing parameters for the recipient phone number, sender, and SMS message text. It then makes an HTTP GET request to the URL and outputs the response.

Uploaded by

Ace Mirxa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
110 views

Oracle Database Sms Gateway

This document provides a code example for sending SMS messages from an Oracle database through a third-party SMS gateway web service portal. The code declares HTTP request and response objects and constructs a URL to call the SMS gateway API, passing parameters for the recipient phone number, sender, and SMS message text. It then makes an HTTP GET request to the URL and outputs the response.

Uploaded by

Ace Mirxa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Oracle Database, Send SMS through

SMS Gateway

Tested on 10g 10.2.0.3 database with default


installation(no additional packages were installed to
achieve the results)

There are many APIs (developed by 3rd parties) which will


allow you to send SMS from a Oracle database on demand.
Many times such APIs would become costly, depending upon
your requirements.

Here, we are providing a zero cost solution, incase if your SMS


gateway provider allows you to send SMS through a web
service portal.

You may wrap the entire procedure and call it against a table
trigger or through a button click available with user form(s)

DECLARE
HTTP_REQ UTL_HTTP.REQ;
HTTP_RESP UTL_HTTP.RESP;
URL_TEXT VARCHAR2(32767);
URL VARCHAR2(2000);

SMS_MSG VARCHAR2(160) := 'Congratulations! Your database has been


configured propoerly for sending SMS through a 3rd party SMS Gateway';

BEGIN
DBMS_OUTPUT.ENABLE(1000000);
--Based on your service provider, the following link format may differ from
--What we have specified below!

URL :=
'http://yourwebsmsdomain.com/alerts/api/web2sms.php?username=demo&password=de
mo2&to=95xxxxxxx&sender=ODBSMS&message='||
UTL_URL.Escape(SMS_MSG,TRUE);
--UTL_URL.Escape manages escape characters like SPACE between words in a
message.
HTTP_REQ := UTL_HTTP.BEGIN_REQUEST(URL);

UTL_HTTP.SET_HEADER(HTTP_REQ, 'User-Agent', 'Mozilla/4.0');


HTTP_RESP := UTL_HTTP.GET_RESPONSE(HTTP_REQ);

-- Process Request
LOOP
BEGIN
URL_TEXT := null;
UTL_HTTP.READ_LINE(HTTP_RESP, URL_TEXT, TRUE);
DBMS_OUTPUT.PUT_LINE(URL_TEXT);

EXCEPTION
WHEN OTHERS THEN EXIT;
END;
END LOOP;

UTL_HTTP.END_RESPONSE(HTTP_RESP);
END;

You might also like