On 26 July 2010 17:27, Zarko Zivanovic <[email protected]> wrote:
> I tried this:
>
>
>
> loc = $agi.get_variable('EXTEN')
>
> $my.query("UPDATE call_log SET local = #{loc}, endtime = NOW() WHERE id =
> #{call_log_id}")
>
>
>
> No success. Anybody please help!
>
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Leif Madsen
> Sent: Monday, July 26, 2010 3:44 PM
> To: [email protected]
> Subject: Re: [asterisk-users] URgent - capturing 'answered'
>
> On 10-07-26 08:10 AM, Zarko Zivanovic wrote:
>> Hello Steve and thanks for your answer,
>> However I tried:
>>
>> $my.query("UPDATE call_log SET local='#{CDR(dstchannel)}', endtime = NOW()
>> WHERE id = #{call_log_id}")
>>
>> And it does write nothing to the database.
>>
>> I guess there is a error in ruby expression above but I am not sure what
> is
>> wrong - if you have any idea please help.
>
> If that is your literal quote, then I think you need to change the # to a $
> as
> Asterisk dialplan functions and variables start with ${ vs #{
>
> Unless that is some special indication in SQL that I'm unfamiliar with.
>
> Leif Madsen.


The "#" prefix is probably something to do with the combination of
Ruby, MySQL and AGI - I am not particularly familiar with Ruby.

You do not say at what stage when you call your AGI in the call path,
and at what stage you access the database.

1) Use AGI In order to make the call, and do not exit AGI until after
the call is over:
2) Call AGI after call is over

In case 1) you'll need the following somewhere in your script after
the call is answered or completed.
    $agi.execute('Set(LOC=${CDR(dstchannel)})')
In case 2) just put
    Set(LOC=${CDR(dstchannel)})
in your dialplan before calling the AGI

Then in your script try:
   loc = $agi.get_variable('LOC')

CDR() is a built-in function rather than a variable, hence the need
for the indirection.

I am still guessing a bit here... Good luck.

Cheers,
Steve

-- 
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
               http://www.asterisk.org/hello

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

Reply via email to