I have a problem with nextval
function, I have a custom sequence in my DB called InternalCodes
and when i want to make a insert like this:
insert into "Membership" ("Name", "Code", "Price", "Caducity", "Status", "Type") values ('asd', nextval("InternalCodes"), 1, 2, true, 0);
PostgreSQL returns me the following error:
org.jkiss.dbeaver.model.sql.DBSQLException: SQL Error [42703]: ERROR: column does not exist «InternalCodes»
Advertisement
Answer
You need to use single quotes instead of double quotes:
test=# create sequence seq_test; test=# select nextval("seq_test"); ERROR: column "seq_test" does not exist LINE 1: select nextval("seq_test"); ^ test=# select nextval('seq_test'); nextval --------- 1
In your case, since your sequence name contains upper case letters, you actually need to use both:
insert into "Membership"("Name", "Code", "Price","Caducity","Status","Type") values('asd', nextval('"InternalCodes"'), 1,2,true,0) ;