Ask Your Question

Revision history [back]

Hi Sujata,

The read-only connection will enforce read privilege for the session. When using the PG function nextval(), a write is made back to PG to advance the sequence. This modification will not occur when in read-only session which is why PG sends back the error: "cannot execute nextval() in a read-only transaction".

The risk of unchecking "Enforce read-only connection" would depend on your level of privilege in the DBMS. In this instance, you are modifying a sequence. Is that allowed by your DBA?

Alternatives. Depending on your usage, you could attach the sequence directly to the PG table. For example, if the sequence is being used as a primary key, you could add the nextval() function to the DDL.

Example: CREATE TABLE foo ( id integer NOT NULL DEFAULT nextval('my_seq') PRIMARY KEY, col_a VARCHAR(50), col_b VARCHAR(50));