<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
On 4/10/2012 9:20 AM, Miha wrote:
<blockquote cite="mid:4F83DF2C.4020904@softnet.si" type="cite">
<meta http-equiv="content-type" content="text/html;
charset=ISO-8859-1">
Hi,<br>
<br>
I need a little help. I am trying to use example for inserting XML
to mysql cdrtable. I have add id before caller_id_name as I need
Id in mysql table. Problem is that I am getting random numbers in
ID field, sometimes values for ID are the same, so sql perl script
return error and values are not inserted.<br>
<br>
Can you help me how can I modify so that this will work properly.<br>
<br>
<small>use strict;<br>
use warnings;<br>
use CGI;<br>
use DBI;<br>
use Data::Dump qw(dump);<br>
$|++;<br>
my $q = CGI->new;<br>
my $raw_cdr = $q->param('cdr');<br>
<br>
my @all_fields = qw(id caller_id_name caller_id_number<br>
destination_number context start_stamp answer_stamp end_stamp<br>
duration billsec hangup_cause uuid bleg_uuid<br>
accountcode domain_name);<br>
my @fields;<br>
my @values;<br>
foreach my $field (@all_fields) {<br>
next unless $raw_cdr =~ m/$field>(.*?)</;<br>
push @fields, $field;<br>
push @values, "'" . urldecode($1) . "'";<br>
}<br>
my $cdr_line;<br>
my $query = sprintf(<br>
"INSERT INTO %s (%s) VALUES (%s);",<br>
'radacct_1', join(',', @fields), join(',', @values)<br>
);<br>
my $db =
DBI->connect('DBI:mysql:dbname=voipbill_slo;host=xxx.xxx.xxx.xxx','xxxxxx',
'xxxxx');<br>
$db->do($query);<br>
print $q->header();<br>
sub urldecode {<br>
my $url = shift;<br>
$url =~ s/%([a-fA-F0-9]{2,2})/chr(hex($1))/eg;<br>
return $url;<br>
}<br>
[root@fs1 cgi-bin]# cat /var/log/secure</small><br>
<br>
Thank you!<br>
<br>
Regards,<br>
Miha<br>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_________________________________________________________________________
Professional FreeSWITCH Consulting Services:
<a class="moz-txt-link-abbreviated" href="mailto:consulting@freeswitch.org">consulting@freeswitch.org</a>
<a class="moz-txt-link-freetext" href="http://www.freeswitchsolutions.com">http://www.freeswitchsolutions.com</a>
FreeSWITCH-powered IP PBX: The CudaTel Communication Server
<a class="moz-txt-link-freetext" href="http://www.cudatel.com">http://www.cudatel.com</a>
Official FreeSWITCH Sites
<a class="moz-txt-link-freetext" href="http://www.freeswitch.org">http://www.freeswitch.org</a>
<a class="moz-txt-link-freetext" href="http://wiki.freeswitch.org">http://wiki.freeswitch.org</a>
<a class="moz-txt-link-freetext" href="http://www.cluecon.com">http://www.cluecon.com</a>
FreeSWITCH-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</a>
<a class="moz-txt-link-freetext" href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a>
UNSUBSCRIBE:<a class="moz-txt-link-freetext" href="http://lists.freeswitch.org/mailman/options/freeswitch-users">http://lists.freeswitch.org/mailman/options/freeswitch-users</a>
<a class="moz-txt-link-freetext" href="http://www.freeswitch.org">http://www.freeswitch.org</a>
</pre>
</blockquote>
HI,<br>
<br>
I was having same problem with auto increment in mysql.<br>
<br>
Now it works.<br>
<br>
Regards,<br>
Miha<br>
</body>
</html>