[asterisk-users] AEL - SQL and TIMEDIFF()

Andreas Sikkema andreas.sikkema at bbeyond.nl
Thu Mar 6 06:48:11 CST 2008


> context testsql {
>   s => {
>     MYSQL(Connect connid ${DBHOST} ${DBUSER} ${DBPASS} ${DB});
>     MYSQL(Query resultid ${connid} SELECT 
> TIMEDIFF(callend,callstart) FROM tblCall WHERE id=7);
>     MYSQL(fetch fetchid ${resultid} temp);
>     MYSQL(Disconnect ${connid});
>   }
> }
> </CODE>
> 
> The error I'm getting is below: 
> [Mar  6 08:59:35] WARNING[27116]: app_addon_sql_mysql.c:268 
> aMYSQL_query: aMYSQL_query: mysql_query failed. Error: You 
> have an error in your SQL syntax; check the manual that 
> corresponds to your MySQL server version for the right syntax 
> to use near ') FROM tblCall WHERE id=7' at line 1

I think the solution would be to escape the , with a backslash, so 
your query would look like this:
SELECT TIMEDIFF(callend\,callstart) FROM tblCall WHERE id=7

Maybe even the brackets ()....

-- 
Andreas Sikkema



More information about the asterisk-users mailing list