Tracking with MySQL : Originate / agi / dialplan

Here the context:

I want to make calls on demand. I could use a call file or Action : Originate. I’ll choose the action, because I want to create a web base application to make call. I want to keep trace of the calls, answered or not. I’ll use Mysql, could be any database.

Here the use cases that I tough. (I don’t know which one is better, I need your advices please)

case 1 :
in java

Insert in mysql with status = 0
do a Action : Originate
if OriginateResponse == SUCCESS status=1, else status=2
update mysql with status for this phone number.

case 2 :

Action : Originate
call a AGI script (I only did the hello world example, I have no idea how I could do that here)
do the sql in the agi script ?

case 3 : took the example : viewtopic.php?t=23834
OriginateAction dial = new OriginateAction();

exten => DIAL,1,Verbose(1,About to perform outdial)
exten => DIAL,n,Dial(${dial_string},30)
exten => DIAL,n,Agi(agi://${DIALSTATUS})
exten => DIAL,n,Hangup()

exten => ANSWERED,1,Answer()
exten => ANSWERED,n,Agi(agi://
exten => ANSWERED,n,Hangup()

I think I could replace the call AGI, by sql insert in mysql ?

What do you think ?