<div dir="ltr"><div><div>Hello, <br><br>Still about CDR and MySQL table, should the calldate field be inserted by Asterisk?<br></div><br></div>This is the table structure we are using, based on Asterisk wiki:<br><br><span style="font-family:courier new,monospace">mysql&gt; describe cdr;<br>

+-------------+-----------------------+------+-----+---------------------+----------------+<br>
| Field       | Type                  | Null | Key | Default             | Extra          |<br>+-------------+-----------------------+------+-----+---------------------+----------------+<br>| id          | mediumint(8) unsigned | NO   | PRI | NULL                | auto_increment |<br>


| calldate    | datetime              | NO   |     | 0000-00-00 00:00:00 |                |<br>| clid        | varchar(80)           | NO   |     |                     |                |<br>| src         | varchar(80)           | NO   |     |                     |                |<br>


| dst         | varchar(80)           | NO   |     |                     |                |<br>| dcontext    | varchar(80)           | NO   |     |                     |                |<br>| channel     | varchar(80)           | NO   |     |                     |                |<br>


| dstchannel  | varchar(80)           | NO   |     |                     |                |<br>| lastapp     | varchar(80)           | NO   |     |                     |                |<br>| lastdata    | varchar(80)           | NO   |     |                     |                |<br>


| duration    | int(11)               | NO   |     | 0                   |                |<br>| billsec     | int(11)               | NO   |     | 0                   |                |<br>| disposition | varchar(45)           | NO   |     |                     |                |<br>


| amaflags    | int(11)               | NO   |     | 0                   |                |<br>| accountcode | varchar(20)           | NO   |     |                     |                |<br>| uniqueid    | varchar(32)           | NO   |     |                     |                |<br>


| userfield   | varchar(255)          | NO   |     |                     |                |<br>| peeraccount | varchar(20)           | NO   |     |                     |                |<br>| linkedid    | varchar(32)           | NO   |     |                     |                |<br>


| sequence    | int(11)               | NO   |     | 0                   |                |<br>+-------------+-----------------------+------+-----+---------------------+----------------+<br>20 rows in set (0.01 sec)</span><br>


<div><div><br></div><div>Thank you!<br><br></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/6/4 Olivier <span dir="ltr">&lt;<a href="mailto:oza_4h07@yahoo.fr" target="_blank">oza_4h07@yahoo.fr</a>&gt;</span><br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>OK, then I&#39;ll go with linkedid, uniqueid and sequence number.<br><br></div>Thanks for sharing this on this list<br>

</div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">2013/6/3 Matthew Jordan <span dir="ltr">&lt;<a href="mailto:mjordan@digium.com" target="_blank">mjordan@digium.com</a>&gt;</span><br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div>On 06/03/2013 11:20 AM, Olivier wrote:<br>
&gt; Hi,<br>
&gt;<br>
&gt; When dealing with CDR SQL tables, I always added an auto-incremented<br>
&gt; cdr_id key as a primary key, just in case provided uniqueid key went wrong.<br>
&gt;<br>
&gt; Now I&#39;m facing a situation where I need to insert into a database&#39;s<br>
&gt; table and from the dialplan, a reference to the CDR record which is<br>
&gt; currently processed.<br>
&gt;<br>
&gt; So my questions are:<br>
&gt;<br>
&gt; 1. Can uniqueid/sequence (or uniqueid/sequence/calldate) bundle be<br>
&gt; safely used as CDR&#39;s table primary key  (ie I cannot have any<br>
&gt; uniqueid/sequence combination from one CDR record to match a past<br>
&gt; uniqueid/sequence combination) ?<br>
<br>
</div></div>Possibly. Things to keep in mind:<br>
<br>
* You can run into uniqueid collisions across multiple systems if you do<br>
not specify a system name in asterisk.conf or do not specify a unique<br>
system name in asterisk.conf.<br>
* You can run into uniqueid collisions if your system clock goes<br>
backwards for any reason (the uniqueid for a channel happens to use a<br>
timestamp for its uniqueness)<br>
<br>
Whether or not this is unique enough will be completely dependent on<br>
your overall system configuration.<br>
<br>
In general, the recommended combination that *should* uniquely specify a<br>
CDR (when configured correctly) is linkedid (which should be enabled and<br>
added to your schema), uniqueid, and sequence number, with the asterisk<br>
system name specified.<br>
<br>
--<br>
Matthew Jordan<br>
Digium, Inc. | Engineering Manager<br>
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA<br>
Check us out at: <a href="http://digium.com" target="_blank">http://digium.com</a> &amp; <a href="http://asterisk.org" target="_blank">http://asterisk.org</a><br>
<br>
<br>
<br>
--<br>
_____________________________________________________________________<br>
-- Bandwidth and Colocation Provided by <a href="http://www.api-digital.com" target="_blank">http://www.api-digital.com</a> --<br>
New to Asterisk? Join us for a live introductory webinar every Thurs:<br>
               <a href="http://www.asterisk.org/hello" target="_blank">http://www.asterisk.org/hello</a><br>
<br>
asterisk-users mailing list<br>
To UNSUBSCRIBE or update options visit:<br>
   <a href="http://lists.digium.com/mailman/listinfo/asterisk-users" target="_blank">http://lists.digium.com/mailman/listinfo/asterisk-users</a><br>
</blockquote></div><br></div>
</div></div><br>--<br>
_____________________________________________________________________<br>
-- Bandwidth and Colocation Provided by <a href="http://www.api-digital.com" target="_blank">http://www.api-digital.com</a> --<br>
New to Asterisk? Join us for a live introductory webinar every Thurs:<br>
               <a href="http://www.asterisk.org/hello" target="_blank">http://www.asterisk.org/hello</a><br>
<br>
asterisk-users mailing list<br>
To UNSUBSCRIBE or update options visit:<br>
   <a href="http://lists.digium.com/mailman/listinfo/asterisk-users" target="_blank">http://lists.digium.com/mailman/listinfo/asterisk-users</a><br></blockquote></div><br><br clear="all"><br>-- <br>Jairo Molina Jr∴<br>
        <a href="http://www.intermol.com.br/" target="_blank">http://www.intermol.com.br</a><font face="arial, helvetica, sans-serif"><span style="border-collapse:collapse"><a value="+551183288940"><span dir="ltr"></span></a></span></font>
</div>