SQL to SMS Gateway configuration - SQL templates
This section gives you information on how you can customize the
SQL commands used to access your database tables. The information
presented here is helpful if you wish to setup an SQL to SMS gateway
configuration and you wish to alter the default database table layout.
Default operation of the SMS gateway
By default the SMS gateway uses two database tables. One of the tables
(ozekimessagein) is used for receiving SMS messages. The other
(ozekimessagout) is used sending SMS messages . If an SMS message arrives
to your gateway, it will be inserted to the ozekimessagin
database table using the following SQL command:
INSERT INTO ozekimessagein (sender, receiver, msg, senttime, receivedtime, msgtype, operator)
Before this statement is executed by the SMS gateway the keywords
(e.g.: $originator, $recipient,...) will be
replaced to the corresponding values of the incoming SMS message.
If you want to send an SMS message, you have to create a record in the
ozekimessagout table. The status of the message should be set to "send".
The SMS gateway will read the ozekimessagout
table using the following SQL query to find your message:
SELECT id,sender,receiver,msg,msgtype,operator FROM ozekimessageout WHERE status='send'
After you outgoing SMS messages has been successfully fetched, the record
will be updated using the following SQL command:
UPDATE ozekimessageout SET status='sending' WHERE id='$id'
This indicates that your SMS messages has been accepted for delivery by
the SMS gateway and is saved into the outbox of the SMS gateway. Some time
after this the following events can happen to your message:
- delivered to network
- delivery to network is not possible
- delivered to handset
- delivery to handset is not possible
Depending which one of these events occur one of the following SQL commands
will be executed on your database record:
If the "delivered to network" event occurs:
UPDATE ozekimessageout SET status='sent', senttime='$senttime' WHERE id='$id'
If the "delivery to network is not possible" event occurs:
UPDATE ozekimessageout SET status='notsent' WHERE id='$id'
If the "delivered to handset" event occurs:
UPDATE ozekimessageout SET status='delivered' WHERE id='$id'
If the "delivery to handset is not possible" event occurs:
UPDATE ozekimessageout SET status='undelivered' WHERE id='$id'
If the status of the message stays in "sending", it indicates, that the Ozeki
software has read the message from the database. The message was accepted
for delivery and was stored in the outbox folder, but it was not yet accepted
by the mobile network operator. It means that it is "waiting for delivery".
In this case, if you look at the Graphical User Interface (GUI) of Ozeki NG,
you should see the message in your outbox.
If the status of the message stays in "sending" for a long time, it is highly
probable that the messages are not delivered because the mobile network
is not functioning in your system. To resolve this issue, please check if the
service provider connection's link (SMPP, UCP, CIMD2) is working.
Customized operation of the SMS Gateway
To change this behavior, you should modify the SQL templates used by the SMS
This can be done by opening the "SQL for sending" or the "SQL for receiving" tab
of the "Database configuration form" (Figure 1).
Figure 1 - How to update the SQL templates
On this form you can specify an SQL command that is valid in your database server.
You can put stored procedures and complex SQL statements. As long as the SQL
command can be executed, the SMS gateway can use it.