You can use the MYSQL function to just use an insert or update statement in
your dialplan.  Look at my example below.  Instead of using

exten => s,2,MYSQL(Query resultid ${connid} SELECT\ callerid\ from\
blacklist\ where\ callerid=${ARG1} and blockenabled = 1)

You could use:

exten => s,2,MYSQL(Query resultid ${connid} INSERT INTO\ callerid\
(callerid,blockenabled)\ VALUES\ ('${CALLERID(num)}', '1')\ )

I find that using the ODBC function works best for inserting data into the
MySQL databases.

Have a look at
http://www.voip-info.org/wiki/index.php?page=Asterisk+func+func_odbc.


[globals]
realdb_host=hostnameformysqldb
realdb_user=mysqldbuser
realdb_pass=mysqldbpassword
realdb_db=mysqldbthatcontainsthevoicemailusers

[macro-checkblacklist]
; This Macro will check the blacklist table to see if the callerid of the
; caller exist and blockenabled =1 (TRUE). If the callerid is listed, then
; tell the caller they have been blacklisted and politely HangUp()
;
; ${ARG1} = CallerID of incoming call
;
exten => s,1,MYSQL(Connect connid ${realdb_host} ${realdb_user}
${realdb_pass} ${realdb_db})
exten => s,2,MYSQL(Query resultid ${connid} SELECT\ callerid\ from\
blacklist\ where\ callerid=${ARG1} and blockenabled = 1)
exten => s,3,MYSQL(Fetch fetchid ${resultid} blacklistid)
exten => s,4,MYSQL(Clear ${resultid})
exten => s,5,MYSQL(Disconnect ${connid})
exten => s,6,GoToIf($[”${blacklistid}” = “”]?7:fail,1)
exten => s,7,NoOp(${blacklistid})
; If the callerid is listed in the database, then send to blacklistednumber
; context
;
exten => fail,1,NoOp(${blacklistid})
exten => fail,2,GoTo(blacklistednumber,s,1)

[blacklistednumber]
; This is where a call will land if the macro-checkblacklist decides that
; the number should not be allowed to dial the company.
exten => s,1,Wait(2)
exten => s,2,Playback(privacy-you-are-blacklisted)
exten => s,3,Zapateller()
exten => s,4,HangUp()



On Wed, Feb 25, 2009 at 3:40 PM, Elliot Murdock <murdo...@gmail.com> wrote:

> Hello Everyone!
>
> According to voip-info.org the correcy syntax for the realtime function
> is:
>
> REALTIME(family|fieldmatch[|value[|delim1[|delim2]]]) on read
> REALTIME(family|fieldmatch|value|field) on write
>
> It seems from the syntax that it is only possible to retrieve a full
> row according to the value of only of column.  This translates in SQL
> language as Select * from family where fieldmath = value.
>
> Is there any way to have more control over the realtime function?
>
> Also, regarding the MYSQL function, I only saw documentation to query
> a database.  Is there any way to update a database using that
> function?
>
> Thanks!
> Elliot
>
> _______________________________________________
> -- Bandwidth and Colocation Provided by http://www.api-digital.com --
>
> asterisk-users mailing list
> To UNSUBSCRIBE or update options visit:
>   http://lists.digium.com/mailman/listinfo/asterisk-users
>



-- 
***
Forrest Beck
IAXTEL: 17002871718
jonforrest.b...@gmail.com
http://www.shift8.biz
_______________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users

Reply via email to