Bridging gammu sms center with oracle DB 10g

I wanna share you a little experiences,
Gammu is one of  free sms gateway that easily to use.
Basic idea is gammu using mysql(Xampp) and
we can remote xmapp using oracle DB10g usnig DBLink



How to configure Gammu using Modem Wavecomm Fastrack M1306B

Hi there i wanna share How to configure Gammu using Modem Wavecomm Fastrack M1306B

Basic tools

 
Win7
Gammu 1.33.0
Modem waveCOM M1306B

 

Let's Begin

Download waveCom M136B Driver here
Download Gammu 1.33.0 here

How to Configure Gammu and wavecom

1.

First, you need to make sure to connect modem and your computer properly
find your modem port COM1,COM2,COM3 etc on Device Manager




2.

Extract Gammu on what ever you want, in my case i placed gammu on drive C:\gammu

if gammu does not work properly
find this file libiconv-2.dll  and copy on C:\windows\system32

3.

setting 2 file bellow gammurc for checking your phone connect properly with gammu
and smsdrc for connecting gammu sms with mysql 

C:\gammu\bin\gammurc

[gammu]

device = com3:
connection = at115200
 
use gammu --identify for checking connection
gammu --identify

 it looks work good then
create user a password a database a on mysql using this file
C:\gammu\share\doc\gammu\examples\sql\mysql.sql


C:\gammu\bin\smsdrc

[gammu]
port = com3:
connection = at115200

[smsd]
service = mysql
logfile =smdlog
debuglevel = 0
PIN = 1234
user = a
password = a
pc = localhost
database = a
 

you need to use  bellow command to install service uninstall start and stop
note : every single change on smsdrc file, you need to re-create service gammu (un install and install service)


gammu-smsd.exe -c smsdrc -i (install service)

gammu-smsd.exe -c smsdrc -u (uninstall service)

gammu-smsd.exe -c smsdrc -s (start service)

gammu-smsd.exe -c smsdrc -k (stop service)


Testing send sms

smsdrc sendsms TEXT 0878xxxxxxxx -text “smsok!"
note : sometimes you can't send message because the number 0 and change it +62 depend on your country code
if you find error 500 on gammu
1.check the smsdrc file
2.recreate service
3.check the signal
4.check your debit
5.check the modem ( it can.t detect with out simcard)
6.you cant use smsdrc sendsms TEXT if the service is running (stop the service and run the command)

 done!

source :
#https://adityasasongko.wordpress.com/2013/07/21/konfigurasi-gammu-menggunakan-modem-wavecomm-fastrack-m1306b/
#http://www.yusiwa.com/download-software-sms/download-driver-modem/

Convert comma separated string to array in pl sql or vice versa aka Array on oracle 10g


  Hi there now day i have a little problem with my documentations.
i rarely noted my work and then when the case came my head is exploding.

before it came too late i wanna note this my experiences about Convert comma separated string to array in pl sql or vice versa.

First Case


I have simple query A,B,C,D and i would like to return the results in one row, like this

XXX
------------
A
B
C
D

f_convert

/* Create the output TYPE, here using a VARCHAR2(100) nested table type */

SQL> CREATE TYPE test_type AS TABLE OF VARCHAR2(100);
   /

Type created.

/* Now, create the function.*/

SQL> CREATE OR REPLACE FUNCTION f_convert(p_list IN VARCHAR2)
      RETURN test_type
    AS
      l_string       VARCHAR2(32767) := p_list || ',';
      l_comma_index  PLS_INTEGER;
      l_index        PLS_INTEGER := 1;
      l_tab          test_type := test_type();
    BEGIN
      LOOP
       l_comma_index := INSTR(l_string, ',', l_index);
       EXIT WHEN l_comma_index = 0;
       l_tab.EXTEND;
       l_tab(l_tab.COUNT) := SUBSTR(l_string, l_index, l_comma_index - l_index);
       l_index := l_comma_index + 1;
     END LOOP;
     RETURN l_tab;
   END f_convert;
   /

Function created.

/* Prove it works */

SQL> SELECT * FROM TABLE(f_convert('A,B,C,D'));

COLUMN_VALUE
--------------------------------------------------------------------------------
A
B
C

D


Second Case

i have
XXX
------------
A
B
C
D

and i would like to return the result like A,B,C,D

String agg

1.

CREATE OR REPLACE TYPE t_string_agg AS OBJECT
(
  g_string  VARCHAR2(32767),

  STATIC FUNCTION ODCIAggregateInitialize(sctx  IN OUT  t_string_agg)
    RETURN NUMBER,

  MEMBER FUNCTION ODCIAggregateIterate(self   IN OUT  t_string_agg,
                                       value  IN      VARCHAR2 )
     RETURN NUMBER,

  MEMBER FUNCTION ODCIAggregateTerminate(self         IN   t_string_agg,
                                         returnValue  OUT  VARCHAR2,
                                         flags        IN   NUMBER)
    RETURN NUMBER,

  MEMBER FUNCTION ODCIAggregateMerge(self  IN OUT  t_string_agg,
                                     ctx2  IN      t_string_agg)
    RETURN NUMBER
);
/
SHOW ERRORS

2.

CREATE OR REPLACE TYPE BODY t_string_agg IS
  STATIC FUNCTION ODCIAggregateInitialize(sctx  IN OUT  t_string_agg)
    RETURN NUMBER IS
  BEGIN
    sctx := t_string_agg(NULL);
    RETURN ODCIConst.Success;
  END;

  MEMBER FUNCTION ODCIAggregateIterate(self   IN OUT  t_string_agg,
                                       value  IN      VARCHAR2 )
    RETURN NUMBER IS
  BEGIN
    SELF.g_string := self.g_string || ',' || value;
    RETURN ODCIConst.Success;
  END;

  MEMBER FUNCTION ODCIAggregateTerminate(self         IN   t_string_agg,
                                         returnValue  OUT  VARCHAR2,
                                         flags        IN   NUMBER)
    RETURN NUMBER IS
  BEGIN
    returnValue := RTRIM(LTRIM(SELF.g_string, ','), ',');
    RETURN ODCIConst.Success;
  END;

  MEMBER FUNCTION ODCIAggregateMerge(self  IN OUT  t_string_agg,
                                     ctx2  IN      t_string_agg)
    RETURN NUMBER IS
  BEGIN
    SELF.g_string := SELF.g_string || ',' || ctx2.g_string;
    RETURN ODCIConst.Success;
  END;
END;
/
SHOW ERRORS

3.

CREATE OR REPLACE FUNCTION string_agg (p_input VARCHAR2)
RETURN VARCHAR2
PARALLEL_ENABLE AGGREGATE USING t_string_agg;
/
SHOW ERRORS


How to use

select string_AGG(X) from xxx


Done!

source :
Comma to array
#http://stackoverflow.com/questions/3819375/convert-comma-separated-string-to-array-in-pl-sql
#
http://stackoverflow.com/questions/468990/how-can-i-combine-multiple-rows-into-a-comma-delimited-list-in-oracle
String_agg (arry to comma)
#https://oracle-base.com/articles/misc/string-aggregation-techniques