[SOLVED]INSERT INTO via dialplan

Goodmorning i had configured this dialplan on extension.conf into asterisk

[test]
exten => s,1,Answer();
exten => s,n,Playback(welcome);
exten => s,n,SayDigits(1);
;exten => s,n,SayAlpha(Accettare);
exten => s,n,SayDigits(2);
;exten => s,n,SayAlpha(Declinare);
;exten => s,n,Read(pippo,enter-ext-of-person);
;exten => s,n,SayNumber(${pippo});
exten => s,n,WaitExten();

exten => 1,1,Playback(you-entered);
exten => 1,n,SayDigits(${EXTEN});
exteb => 1,n,MYSQL(Connect connid localhost marco marco finaziamenti)
exten => 1,n,MYSQL(Query resultid ${connid} 'INSERT INTO ‘a’(‘a’) Values (1);
exten => 1,n,MYSQL(Clear ${resultid});
exten => 1,n,MYSQL(Disconnect ${connid});
exten => 1,n,Wait(2);
exten => 1,n,Playback(hello-world);

exten => 2,1,Playback(you-entered);
exten => 2,n,SayDigits(${EXTEN});
exten => 2,n,Read(number)
exten => 2,n,SayDigits(${number});
exten => 2,n,Wait(2);
exten => 2,n,Playback(goodbye);

when the user types 1 should insert into the table the record set but nothing happen
the db user have all privileges and grant option on db

table a with column a INT

i hope somebody could help me

thanks

quotes & parethesis dont match

MYSQL(Query resultid ${connid} INSERT INTO a (a) Values (1))

is more likely to work - depending on your db schema

note also that the mysql addon is deprecated (as you can see in make menuselect) and that you should use odbc

try don’t work :frowning:

is better use odbc?

thanks

i can select with this:

exten => 1,n,MYSQL(Connect connid localhost marco marco asterisk)
exten => 1,n,MYSQL(Query resultid ${connid} SELECT count(a) from a)
exten => 1,n,MYSQL(Fetch fetchid ${resultid} COUNTER)
exten => 1,n,MYSQL(Clear ${resultid})
exten => 1,n,MYSQL(Disconnect ${connid})
exten => 1,n,Playback(the-num-i-have-is)
exten => 1,n,SayNumber(${COUNTER})

but can’t insert with this

exten => 1,n,MYSQL(Connect connid localhost marco marco asterisk)
exten => 1,n,MYSQL(Query resultid ${connid} INSERT INTO a (a) Values (1))
exten => 1,n,MYSQL(Clear ${resultid})
exten => 1,n,MYSQL(Disconnect ${connid})

test first the statement in mysql

this work
exten => 1,n,MYSQL(Connect connid localhost marco marco asterisk)
exten => 1,n,MYSQL(Query resultid ${connid} SELECT count(a) from a)
exten => 1,n,MYSQL(Fetch fetchid ${resultid} COUNTER)
exten => 1,n,MYSQL(Clear ${resultid})
exten => 1,n,MYSQL(Disconnect ${connid})
exten => 1,n,Playback(the-num-i-have-is)
exten => 1,n,SayNumber(${COUNTER})

this no
xten => 1,n,MYSQL(Connect connid localhost marco marco asterisk)
exten => 1,n,MYSQL(Query resultid ${connid} INSERT INTO a (a) Values (1))
exten => 1,n,MYSQL(Clear ${resultid})
exten => 1,n,MYSQL(Disconnect ${connid})

solved i found the error,

is not

exten => 1,n,MYSQL(Query resultid ${connid} INSERT INTO a (a) Values (1))

is

exten => 1,n,MYSQL(Query resultid ${connid} INSERT INTO a (a) VALUES (1))

case sensitive :slight_smile:

thanks for support

1 Like