0

This is DDL for the table:

CREATE TABLE public.res_partner (
    id serial NOT NULL,
    CONSTRAINT res_partner_pkey PRIMARY KEY (id)
);

This is SQL:

insert into public.res_partner () values ();

and the error:

SQL Error [42601]: ERROR: syntax error at or near ")"
  Position: 33
$ psql --version
psql (PostgreSQL) 11.1 (Ubuntu 11.1-1.pgdg18.04+1)

I see that this statement is absolutely legal. My code worked 2-3 days ago (PHP with Doctrine). But now I cannot execute this statement from dBeaver client and from my app.

1
  • I used ORM in my code before (when it worked) then I switched to DBAL. The query insert into public.res_partner () values (); was generated by DBAL module.
    – Alex Gusev
    Mar 13, 2019 at 16:38

1 Answer 1

2

Your linked question is for MySQL which doesn't really have a track record for valid standard SQL - and having an empty column list or empty values list is far from being "legal" syntax in standard SQL or Postgres.

If you want to insert the default values you have two choices

insert into public.res_partner (id) values (default);

Or if you do not want to specify the column name, use:

insert into public.res_partner
default values;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.