Skip to main content
Known Participant
April 4, 2011
Answered

Null for Postgres nextval

  • April 4, 2011
  • 1 reply
  • 727 views

Hello,

I'm trying to insert some values into a postgres table, first column of which is a serial type.

So I'm doing

INSERT INTO users (

  <cfqueryparam null="yes" cfsqltype="cf_sql_integer">,

  <cfqueryparam ....

)

and so on. PG raises an error, "null value in column "id_user" violates not-null constraint"

How can I fix it?

thanks....

This topic has been closed for replies.
Correct answer JR__Bob__Dobbs

I'm not a Postresql expert, but I suspect you need to omit the id_user column from your insert statement to allow the server to assign a value to the column.

Try specifying  your column names in your SQL statement like, note that id_user is omitted in the INSERT statement.

INSERT INTO users ( last_name, first_name )

VALUES ( <cfqueryparam value="#form.last_name#" cfsqltype="cf_sql_varchar">, <cfqueryparam value="#form.first_name#" cfsqltype="cf_sql_varchar"> );

1 reply

JR__Bob__DobbsCorrect answer
Inspiring
April 4, 2011

I'm not a Postresql expert, but I suspect you need to omit the id_user column from your insert statement to allow the server to assign a value to the column.

Try specifying  your column names in your SQL statement like, note that id_user is omitted in the INSERT statement.

INSERT INTO users ( last_name, first_name )

VALUES ( <cfqueryparam value="#form.last_name#" cfsqltype="cf_sql_varchar">, <cfqueryparam value="#form.first_name#" cfsqltype="cf_sql_varchar"> );