Couldn't execute statement: SQL logic error

Hello All,

I am new here in Asterisk. Can any help me line by line on below error

Couldn’t execute statement: SQL logic error
Unable to open file /var/log/asterisk//cdr-csv//Master.csv : Permission denied
Unable to write CSV record to master ‘/var/log/asterisk//cdr-csv//Master.csv’ : Permission denied

Thanks

I would guess you are running Asterisk as a user that doesn’t have permission to access such things.

On Wednesday 25 June 2025 at 11:50:49, shazeb via Asterisk Community wrote:

Couldn’t execute statement: SQL logic error

No idea about that unless you tell us what you’re doing with SQL in an
Asterisk setup.

Give us more context for that error message.

Unable to open file /var/log/asterisk//cdr-csv//Master.csv : Permission
denied

The ownership and permissions on that file do not allow the user Asterisk is
run as to open it.

Show us the output of:

ls -l /var/log/asterisk//cdr-csv/Master.csv

and
ps aux | grep asterisk

Unable to write CSV record to master ‘/var/log/asterisk//cdr-
csv//Master.csv’ : Permission denied

Same as above.

Antony.


“The tofu battle I saw last weekend was quite brutal.”

  • Marija Danute Brigita Kuncaitis

Thanks for prompt reply jcolp

I am using Ubuntu operating system and running all command in root user.

ls: cannot access ‘/var/log/asterisk//cdr-csv/Master.csv’: No such file or directory

On Wednesday 25 June 2025 at 12:13:30, shazeb via Asterisk Community wrote:

ls: cannot access ‘/var/log/asterisk//cdr-csv/Master.csv’: No such file or
directory

Okay, so let’s see

ls -l /var/log/asterisk/cdr-csv

Don’t forget also to show us

ps aux | grep asterisk

Antony.


“I estimate there’s a world market for about five computers.”

  • Thomas J Watson, Chairman of IBM

On Wednesday 25 June 2025 at 12:12:03, shazeb via Asterisk Community wrote:

I am using Ubuntu operating system

How did you install Asterisk?

Antony.


Too many people spend money they haven’t earned
to buy things they don’t want,
to impress people they don’t like.

  • Will Rogers

root@user-H610M-K-DDR4:~# ps aux | grep asterisk
asterisk 1970 0.7 0.2 5421292 87064 ? Ssl 13:51 0:54 /usr/sbin/asterisk -U asterisk -G asterisk
root 2193 0.0 0.0 49400 8792 pts/0 T 13:55 0:00 rasterisk vrrr
root 14221 0.0 0.0 49400 8756 pts/0 T 15:45 0:00 rasterisk r
root 14447 0.0 0.0 9040 724 pts/0 S+ 15:47 0:00 grep --color=auto asterisk

https://computingforgeeks.com/install-asterisk-20-lts-on-ubuntu/

to followed the step from above URL. I am in learning stage, if you have any suggestion thn please help me to build asterisk

On Wednesday 25 June 2025 at 12:30:06, shazeb via Asterisk Community wrote:

asterisk 1970 0.7 0.2 5421292 87064 ? Ssl 13:51 0:54
/usr/sbin/asterisk -U asterisk -G asterisk

So, Asterisk is running as the user “asterisk” and you have not yet shown us
the output of:

ls -l /var/log/asterisk/cdr-csv

My guess is that the directory is owned by root and the “asterisk” user cannot
write to it.

Antony.


International affairs can be complicated.
On 28th June 1914 a Serb shot an Austrian in Bosnia, so five weeks later
Germany invaded Luxembourg, declared war on France, and then invaded Belgium,
which caused Britain to enter the war.

On Wednesday 25 June 2025 at 12:34:25, shazeb via Asterisk Community wrote:

https://computingforgeeks.com/install-asterisk-20-lts-on-ubuntu/

Those instructions include:

sudo chown -R asterisk.asterisk /var/{lib,log,spool}/asterisk

Please confirm whether you did that, and show us the output of the command:

ls -ld /var/{lib,log,spool}/asterisk

Antony.


What do you call a dinosaur with only one eye? A Doyouthinkesaurus.

I just run command - ```
sudo chown -R asterisk.asterisk /var/{lib,log,spool}/asterisk

and after that - ls -ld /var/{lib,log,spool}/asterisk

Getting below result
root@user-H610M-K-DDR4:~# ls -ld /var/{lib,log,spool}/asterisk
drwxr-xr-x 14 asterisk asterisk 4096 Jun 24 19:33 /var/lib/asterisk
drwxr-xr-x 5 asterisk asterisk 4096 Jun 24 19:33 /var/log/asterisk
drwxr-xr-x 10 asterisk asterisk 4096 Jun 24 19:33 /var/spool/asterisk

now i am not getting the access denied statement but getting Couldn’t execute statement: "SQL logic error " after hangup the call

On Wednesday 25 June 2025 at 13:16:11, shazeb via Asterisk Community wrote:

I just run command -
sudo chown -R asterisk.asterisk /var/{lib,log,spool}/asterisk

So now we have no idea whether the ownerships were set correctly beforehand or
not.

Antony.


Schrödinger’s rule of data integrity: the condition of any backup is unknown
until a restore is attempted.

On Wednesday 25 June 2025 at 13:18:52, shazeb via Asterisk Community wrote:

now i am not getting the access denied statement

This tells me that you did not follow all the steps in the instructions you
pointed to, and that the command you just ran to set the ownership on the
directories has corrected this omission.

We have no way of knowing whether you missed any other steps in the
instructions.

Couldn’t execute statement: "SQL logic error "

Explain what you are doing with SQL in an Asterisk setup.

Antony.


BASIC is to computer languages what Roman numerals are to arithmetic.

Actually when i am dialing the number from soft phone using extension, there is no live logs generate and getting SQL error.

[Jun 25 16:42:28] WARNING[2030]: db.c:362 ast_db_put: Couldn’t execute statement: SQL logic error
[Jun 25 16:43:23] WARNING[2030]: db.c:362 ast_db_put: Couldn’t execute statement: SQL logic error
[Jun 25 16:44:17] WARNING[2030]: db.c:362 ast_db_put: Couldn’t execute statement: SQL logic error
[Jun 25 16:44:37] NOTICE[2030]: chan_sip.c:28829 handle_request_subscribe: Received SIP subscribe for peer without mailbox: 100
[Jun 25 16:45:11] WARNING[2030]: db.c:362 ast_db_put: Couldn’t execute statement: SQL logic error
[Jun 25 16:46:06] WARNING[2030]: db.c:362 ast_db_put: Couldn’t execute statement: SQL logic error
[Jun 25 16:47:00] WARNING[2030]: db.c:362 ast_db_put: Couldn’t execute statement: SQL logic error
[Jun 25 16:47:37] NOTICE[2030]: chan_sip.c:28829 handle_request_subscribe: Received SIP subscribe for peer without mailbox: 100
[Jun 25 16:47:54] WARNING[2030]: db.c:362 ast_db_put: Couldn’t execute statement: SQL logic error
[Jun 25 16:48:48] WARNING[2030]: db.c:362 ast_db_put: Couldn’t execute statement: SQL logic error
[Jun 25 16:49:43] WARNING[2030]: db.c:362 ast_db_put: Couldn’t execute statement: SQL logic error
[Jun 25 16:50:37] WARNING[2030]: db.c:362 ast_db_put: Couldn’t execute statement: SQL logic error
[Jun 25 16:50:37] NOTICE[2030]: chan_sip.c:28829 handle_request_subscribe: Received SIP subscribe for peer without mailbox: 100
[Jun 25 16:51:31] WARNING[2030]: db.c:362 ast_db_put: Couldn’t execute statement: SQL logic error
[Jun 25 16:51:35] WARNING[2042]: db.c:362 ast_db_put: Couldn’t execute statement: SQL logic error
[Jun 25 16:51:35] WARNING[2042]: db.c:362 ast_db_put: Couldn’t execute statement: attempt to write a readonly database
[Jun 25 16:52:25] WARNING[2030]: db.c:362 ast_db_put: Couldn’t execute statement: SQL logic error
[Jun 25 16:53:20] WARNING[2030]: db.c:362 ast_db_put: Couldn’t execute statement: SQL logic error
[Jun 25 16:53:38] NOTICE[2030]: chan_sip.c:28829 handle_request_subscribe: Received SIP subscribe for peer without mailbox: 100
[Jun 25 16:54:14] WARNING[2030]: db.c:362 ast_db_put: Couldn’t execute statement: SQL logic error
[Jun 25 16:55:08] WARNING[2030]: db.c:362 ast_db_put: Couldn’t execute statement: SQL logic error
[Jun 25 16:56:03] WARNING[2030]: db.c:362 ast_db_put: Couldn’t execute statement: SQL logic error
[Jun 25 16:56:33] WARNING[2030]: db.c:362 ast_db_put: Couldn’t execute statement: SQL logic error
[Jun 25 16:56:38] NOTICE[2030]: chan_sip.c:28829 handle_request_subscribe: Received SIP subscribe for peer without mailbox: 100
[Jun 25 16:56:57] WARNING[2030]: db.c:362 ast_db_put: Couldn’t execute statement: SQL logic error

On Wednesday 25 June 2025 at 13:45:03, shazeb via Asterisk Community wrote:

Actually when i am dialing the number from soft phone using extension,
there is no live logs generate and getting SQL error.

Please explain what you are doing with SQL in this Asterisk setup.

There is nothing to do with SQL in the instructions you pointed to previously,
so what have you done in addition which involves SQL?

Antony.


It is also possible that putting the birds in a laboratory setting
inadvertently renders them relatively incompetent.

  • Daniel C Dennett

i am not doing any thing with sql in asterisk . I just wanted to know why this error is coming and when i am not getting live packet.
Actually i am just beginner in asterisk.

This is astdb, which is used for data persistence in some Asterisk modules, even without explicit requests from user configuration. I’d say that Asterisk hadn’t been installed properly, so I’d want to know how it had been installed.

On Wednesday 25 June 2025 at 14:40:31, shazeb via Asterisk Community wrote:

i am not doing any thing with sql in asterisk

In that case please give us a lot more context for that error message.

At a minimum (give us as much detail as you think could be helpful):

  • where does it appear?
  • when does it appear?
  • what precedes it?

Antony.


Ich habe gerade ein besonderes Bier getrunken.
Jetzt habe ich kein Bock mehr :frowning: