By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,649 Members | 696 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,649 IT Pros & Developers. It's quick & easy.

Insert value to auto increment colomn

P: 250
I'm a new to postgres. i have a table which is having a colomn with auto increment value. When I insert value to that table, it gives an error.

$pgsql = "INSERT INTO xxx VALUES (null,'$FullName', '$DoB', '$Address','$PhnNo' )";

Error in SQL query: ERROR: null value in column "No" violates not-null constraint

First column is the auto increment one.
Could some one help me?
Jun 3 '09 #1
Share this Question
Share on Google+
1 Reply

Expert 100+
P: 700
If it is autoincrement column, why do yo want to put a value here. Let postgres put this value, unless you have a good reason to put value by yourself.

To let postgres to put a value write
Expand|Select|Wrap|Line Numbers
for example
Expand|Select|Wrap|Line Numbers
  1. $pgsql = "INSERT INTO xxx(full_name,some_column,address,phone) VALUES ('$FullName', '$DoB', '$Address','$PhnNo' )"; 
Jun 5 '09 #2

Post your reply

Sign in to post your reply or Sign up for a free account.