Dial Plan + Application

Hello. I need write values in db of asterisk. I can to do when i call to ura, but when i to call to sip i can’t. As insert the function when sip answer call?

[code][grupo1]
inclue => demo

;xlite
exten => 6601,1,Dial(SIP/6601,25,tT)

;iphone
exten => 6602,1,Dial(SIP/6602,25,tT)

;ura
exten => 6600,1,Goto(ura,s,1)

[ura]
exten => s,1,Answer()
exten => s,2,System(mysql -u root -h localhost -e “INSERT INTO teste(channel,data) VALUES(NULL,’${CHANNEL}’)” --password=root teste_asterisk)
exten => s,3,Wait(2)
exten => s,4,SayAlpha(3544-1000)
exten => s,5,goto(ura,s,1)
[/code]