I'm trying to do an sql_pvquery() and have PostgreSQL return the default value using COALESCE (if the other parts of the query return NULL) rather than placing the $null check on the return in the Kamailio script. I seem to be coming up on a parser issue, perhaps too many nested parentheses:
sql_pvquery("kamailio", "SELECT COALESCE((SELECT value FROM usr_preferences WHERE attribute='callee_rtp_transport' AND (uuid='$sht(rtpengine=>$ci::$T_branch_idx::callee_ip)' OR username='$rU') LIMIT 1), 'RTP/AVP')", "$sht(rtpengine=>$ci::$T_branch_idx::callee_rtp_transport)");
<core> [cfg.y:3428]: yyerror_at(): parse error in config file /etc/kamailio/kamailio.cfg, line 1444, column 14: syntax error
Is this query "too complex" for the parser, or is there something I've missed above?
Thanks. -A
On Wednesday, March 11, 2015 06:08:04 PM Anthony Messina wrote:
I'm trying to do an sql_pvquery() and have PostgreSQL return the default value using COALESCE (if the other parts of the query return NULL) rather than placing the $null check on the return in the Kamailio script. I seem to be coming up on a parser issue, perhaps too many nested parentheses:
sql_pvquery("kamailio", "SELECT COALESCE((SELECT value FROM usr_preferences WHERE attribute='callee_rtp_transport' AND (uuid='$sht(rtpengine=>$ci::$T_branch_idx::callee_ip)' OR username='$rU') LIMIT 1), 'RTP/AVP')", "$sht(rtpengine=>$ci::$T_branch_idx::callee_rtp_transport)");
<core> [cfg.y:3428]: yyerror_at(): parse error in config file /etc/kamailio/kamailio.cfg, line 1444, column 14: syntax error
Is this query "too complex" for the parser, or is there something I've missed above?
Thanks. -A
Nevermind... I was missing a '}' earlier in the script :( Sorry for the noise. -A
On 03/11/2015 07:12 PM, Anthony Messina wrote:
On Wednesday, March 11, 2015 06:08:04 PM Anthony Messina wrote:
Is this query "too complex" for the parser, or is there something I've missed above?
Thanks. -A
Nevermind... I was missing a '}' earlier in the script :( Sorry for the noise. -A
:-)
Just for information's sake, sql_pvquery() does not parse the SQL query and does not care what is in there, syntactically. The query string is not analysed or mediated by Kamailio's DB API layer or anything of the sort. It's simply passed along directly to Postgres, as-is. So, if there's an issue with the query itself, the error would be returned from Postgres, rather than expressed as a Kamailio runtime syntax error.