<DIV><FONT color=#0000ff>My object</FONT>:&nbsp;&nbsp;&nbsp; get the dialog-based CDRs </DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT color=#0000ff>SIP proxy</FONT>:&nbsp;&nbsp; kamailio-3.2.0</DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT color=#0000ff>My script</FONT>:</DIV>
<DIV>&nbsp;</DIV>
<DIV>loadmodule "dialog.so"</DIV>
<DIV>......</DIV>
<DIV>modparam("dialog","dlg_flag",4)#Must be set to create the dialog associated to an initial request.<BR>modparam("dialog","db_url","mysql://xxx:xxx@localhost/albert")<BR>modparam("dialog","table_name","dialog")</DIV>
<DIV>.......</DIV>
<DIV>request_route{</DIV>
<DIV>&nbsp;&nbsp;&nbsp; if( is_method("INVITE") &amp;&amp; !has_totag())</DIV>
<DIV>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;dlg_setflag(4);</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dlg_var(start_time)=$TS;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dlg_var(caller)=$fU;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dlg_var(caller)=$tU;<BR>&nbsp;&nbsp;&nbsp; }&nbsp;<BR>&nbsp;&nbsp;&nbsp; dlg_manage();</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;......</DIV>
<DIV>&nbsp;&nbsp;&nbsp; # dispatch destinations to PSTN<BR>&nbsp;&nbsp;&nbsp;&nbsp; route(PSTN);</DIV>
<DIV>&nbsp;&nbsp;&nbsp; # user location service<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; route(LOCATION);</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; route(RELAY);</DIV>
<DIV>}</DIV>
<DIV>.........</DIV>
<DIV>route[WITHINDLG] {<BR>&nbsp;&nbsp;&nbsp;&nbsp; if (has_totag()) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # sequential request withing a dialog should<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # take the path determined by record-routing<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (loose_route()) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (is_method("BYE")) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setflag(FLT_ACC); # do accounting ...<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;setflag(FLT_ACCFAILED); # ... even if the transaction fails<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;sql_query("cd", "insert into cdr(caller,callee,start_time,duration) values($dlg_var(caller),$dlg_var(callee),$dlg_var(start_time),$DLG_lifetime)", "rd");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; sql_result_free("rd");&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp; if (is_method("ACK")) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;route(NATMANAGE); # ACK is forwarded statelessy<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;route(RELAY);</DIV>
<DIV>}</DIV>
<DIV>........</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT color=#0000ff>My issue is</FONT> :</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The dialog records can be wrritten into the dialog table.&nbsp; But , the <FONT color=#ff0000>sql_query <FONT color=#000000>can not executed. So the cdr table will not get the CDRs.&nbsp; I don't know why. Who can help me ? </FONT></FONT></DIV>
<P><FONT color=#ff0000><FONT color=#000000>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;This is a simple script for testing.&nbsp; </FONT></FONT></P>
<P><FONT color=#ff0000><FONT color=#000000>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Any suggestion will be appreciated.</FONT></FONT></P>
<P><FONT color=#ff0000><FONT color=#000000>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Thank you in advance.</FONT></P></FONT>
<DIV>&nbsp;</DIV>
<DIV><sign signid="1">
<DIV style="FONT-FAMILY: Arial Narrow; COLOR: #909090; FONT-SIZE: 12px">------------------</DIV>
<DIV style="FONT-FAMILY: Verdana; COLOR: #000; FONT-SIZE: 14px">albert.gu</sign></DIV></DIV>