Duplicate CDR data storing issue

Hello, In my asterisk, I created database using MariaDB. Also I created data table called CDR for storing call details in my database. But After each call, it saved data with duplicate. I mean save same data set twice. How fix this issue?

| 66 | 2024-03-05 09:26:04 | "773xxxxxx" <773xxxxxx> | 773xxxxxx| s    | testing              | PJSIP/registrar-00000000 | NULL                  | BackGround | welcomedmse                         |        4 |       4 | ANSWERED    |        3 | NULL        | 1709610964.0  | NULL                       | 1709610964.0  |
| 67 | 2024-03-05 09:26:04 | "773xxxxxx" <773xxxxxx> | 773xxxxxx| s    | testing              | PJSIP/registrar-00000000 |                       | BackGround | welcomedmse                         |        4 |       4 | ANSWERED    |        3 |             | NULL          |                            | 1709610964.0  |
+

To prevent duplicate entries in your CDR table, you can add a unique constraint to the appropriate columns in your database schema.

ALTER TABLE CDR ADD CONSTRAINT unique_cdr_entry UNIQUE (call_id);

Replace call_id with the appropriate column name that uniquely identifies each call entry. This constraint ensures that no duplicate entries with the same call_id will be inserted into the table.
i hope it will work for you.

Best regard
Danish Hafeez | QA Assistant
ICTInnovations

They are not the same!

Unique constraints are not there to work round this sort of problem. Although there isn’t enough information to understand this particular issue, if you are getting two records when you expect one, it is probably because you don’t understand how CDRs work.

Without the column names, dialplan, and CDR settings, I’m not sure why there are two records, but you should “fix” this by suppressing the second one, without understanding what is happening.

Based on the other post at Not storing destination number in cdr table - #2 by jcolp have you configured Asterisk to write CDRs into the database, but you’re also writing your own records in using func_odbc?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.