Not storing destination number in cdr table

I am trying to save cdr data in database. But not saving destination number. because I have 10 destination number and I need to identify destination number.

This is my CLI showed log information

    -- Executing [s@dmse_IVR:7] Set("PJSIP/registrar-00000000", "DESTINATION_NUMBER=0112xxxxx") in new stack
    -- Executing [s@dmse_IVR:8] Set("PJSIP/registrar-00000000", "ODBC_WRITE("773xxxxx" <0773xxxxx>, 0773xxxxx, '0112xxxxx', dmse_IVR, PJSIP/registrar-00000000, , Set, DESTINATION_NUMBER=0112xxxxx, 0, 0, NO ANSWER, DOCUMENTATION, , 1709636250.0, 1709636250.0, )") in new stack
[Mar  5 16:27:30] WARNING[35023][C-00000001]: pbx_variables.c:1164 pbx_builtin_setvar: Please avoid unnecessary spaces on variables as it may lead to unexpected results ('ODBC_WRITE("773xxxxx" <0773xxxxx>, 0773xxxxx, '0112xxxxx', dmse_IVR, PJSIP/registrar-00000000, , Set, DESTINATION_NUMBER' set to '0112xxxxx, 0, 0, NO ANSWER, DOCUMENTATION, , 1709636250.0, 1709636250.0, )').

And this is my Extension code

; Use DIALED_NUMBER directly to set DESTINATION_NUMBER
   same => n,Set(DESTINATION_NUMBER=${DIALED_NUMBER})

   ; Insert call details into the database including the destination number
   same => n,Set(ODBC_WRITE(${CDR(clid)}, ${CDR(src)}, '${DESTINATION_NUMBER}', ${CDR(dcontext)}, ${CDR(channel)}, ${CDR(dstchannel)}, ${CDR(lastapp)}, ${CDR(lastdata)}, ${CDR(duration)}, ${CDR(billsec)}, ${CDR(disposition)}, ${CDR(amaflags)}, ${CDR(accountcode)}, ${CDR(uniqueid)}, ${CDR(linkedid)}, ${CDR(userfield)}))

But my database stored following data only

| 129 | 2024-03-05 16:27:30 | "773xxxxx" <0773xxxxx> | 0773xxxxx    | s             | NULL               | testing              | PJSIP/registrar-00000000 | NULL                   | BackGround    | welcomedmse                                     |       12 |      12 | ANSWERED          |        3 | NULL              | 1709636250.0  | NULL                       | 1709636250.0   |
| 130 | 2024-03-05 16:27:30 | "773xxxxx" <0773xxxxx> | 0773xxxxx    | s             | NULL               | testing              | PJSIP/registrar-00000000 |                        | BackGround    | welcomedmse                                     |       12 |      12 | ANSWERED          |        3 |                   | NULL          |                            | 1709636250.0   |
+-----+---------------------+--------------------------+---------------+---------------+--------------------+----------------------+--------------------------+------------------------+---------------+-------------------------------------------------+----------+---------+-------------------+----------+-------------------+---------------+----------------------------+----------------+

and this is my cdr table description

MariaDB [asterisk]> desc cdr;
+--------------------+--------------+------+-----+---------+----------------+
| Field              | Type         | Null | Key | Default | Extra          |
+--------------------+--------------+------+-----+---------+----------------+
| id                 | int(11)      | NO   | PRI | NULL    | auto_increment |
| calldate           | datetime     | YES  |     | NULL    |                |
| clid               | varchar(80)  | YES  |     | NULL    |                |
| src                | varchar(80)  | YES  |     | NULL    |                |
| dst                | varchar(80)  | YES  |     | NULL    |                |
| destination_number | varchar(80)  | YES  |     | NULL    |                |
| dcontext           | varchar(80)  | YES  |     | NULL    |                |
| channel            | varchar(80)  | YES  |     | NULL    |                |
| dstchannel         | varchar(80)  | YES  |     | NULL    |                |
| lastapp            | varchar(80)  | YES  |     | NULL    |                |
| lastdata           | varchar(80)  | YES  |     | NULL    |                |
| duration           | int(11)      | YES  |     | NULL    |                |
| billsec            | int(11)      | YES  |     | NULL    |                |
| disposition        | varchar(45)  | YES  |     | NULL    |                |
| amaflags           | int(11)      | YES  |     | NULL    |                |
| accountcode        | varchar(20)  | YES  |     | NULL    |                |
| linkedid           | varchar(32)  | YES  |     | NULL    |                |
| userfield          | varchar(255) | YES  |     | NULL    |                |
| uniqueid           | varchar(32)  | YES  |     | NULL    |                |
+--------------------+--------------+------+-----+---------+----------------+

how fix this issue???

You are calling a func_odbc configured function, but you haven’t provided what that function is configured as.

Can you give correct function or method for this. I have no idea what I do for solve this problem.

On Tue, Mar 5, 2024, 7:04 PM jcolp via Asterisk Community <notifications@asterisk.discoursemail.com> wrote:

jcolp Asterisk Project Lead
March 5

You are calling a func_odbc configured function, but you haven’t provided what that function is configured as.


Visit Topic or reply to this email to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, click here.

You should know what your ODBC_WRITE function is…

It’s configured in func_odbc.conf

I added this code in my func_odbc.conf


[ODBC_WRITE]
dsn=asterisk
writesql=INSERT INTO cdr (calldate, clid, src, dst, destination_number, dcontext, channel, dstchannel, lastapp, lastdata, duration, billsec, disposition, amaflags, accountcode, linkedid, u>


after that, my CLI show like this

    -- Executing [s@dmse_IVR:7] Set("PJSIP/registrar-00000000", "DESTINATION_NUMBER=0112xxxxx") in new stack
    -- Executing [s@dmse_IVR:8] Set("PJSIP/registrar-00000000", "ODBC_WRITE('', '"773xxxxx" <0773xxxxx>', '0773xxxxx', 's', '0112xxxxx', 'dmse_IVR', 'PJSIP/registrar-00000000', '', 'Set', 'DESTINATION_NUMBER=0112xxxxx', 0, 0, 'NO ANSWER', DOCUMENTATION, '', '1709708600.0', '', '1709708600.0')") in new stack
[Mar  6 12:33:20] WARNING[39521][C-00000001]: pbx_variables.c:1164 pbx_builtin_setvar: Please avoid unnecessary spaces on variables as it may lead to unexpected results ('ODBC_WRITE('', '"773xxxxx" <0773xxxxx>', '0773xxxxx', 's', '0112xxxxx', 'dmse_IVR', 'PJSIP/registrar-00000000', '', 'Set', 'DESTINATION_NUMBER' set to '0112xxxxx', 0, 0, 'NO ANSWER', DOCUMENTATION, '', '1709708600.0', '', '1709708600.0')').

But my cdr table of asterisk database show NULL

| 143 | 2024-03-06 12:33:20 | "773xxxxx" <0773xxxxx> | 0773xxxxx    | s             | NULL               | testing              | PJSIP/registrar-00000000 | NULL                   | BackGround    | welcomedmse                                     |        9 |       9 | ANSWERED          |        3 | NULL              | 1709708600.0  | NULL                       | 1709708600.0   |
| 144 | 2024-03-06 12:33:20 | "773xxxxx" <0773xxxxx> | 0773xxxxx    | s             | NULL               | testing              | PJSIP/registrar-00000000 |                        | BackGround    | welcomedmse                                     |        9 |       9 | ANSWERED          |        3 |                   | NULL          |                            | 1709708600.0   |
+-----+---------------------+--------------------------+---------------+---------------+--------------------+----------------------+--------------------------+------------------------+---------------+-------------------------------------------------+----------+---------+-------------------+----------+-------------------+---------------+----------------------------+----------------+
144 rows in set (0.004 sec)

also this time, not added my destination number in my database. are there any issues???

This appears to have been truncated and/or garbled.

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