473,563 Members | 2,831 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Insert value to auto increment colomn

250 Contributor
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,'$FullNam e', '$DoB', '$Address','$Ph nNo' )";

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
1 10987
rski
700 Recognized Expert Contributor
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
  1. $pgsql = "INSERT INTO xxx(HERE WRITE COMMA-SEPARATED COLUMNS WICH YOU FILL WITH VALUES) VALUES ('$FullName', '$DoB', '$Address','$PhnNo' )"; 
  2.  
for example
Expand|Select|Wrap|Line Numbers
  1. $pgsql = "INSERT INTO xxx(full_name,some_column,address,phone) VALUES ('$FullName', '$DoB', '$Address','$PhnNo' )"; 
  2.  
Jun 5 '09 #2

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

Similar topics

5
3001
by: diong | last post by:
i have a field with a list of wrong ID (random) and i wish to replac them with a sequential (auto-increment) value. how to remove the valu and to add in the sequential ID? Im a newbie in ASP! Pls Help - dion ----------------------------------------------------------------------- Posted via http://www.codecomments.co
2
12706
by: Tom | last post by:
I am trying to store information into a table that has an auto increment field. There is currently no data in the table. Using the code below I cannot insert data into the table. I get an error telling me that "Number of query values and destination fields are not the same." If I add a value for the auto increment field to the SQL String...
5
5140
by: Pauloviè Michal | last post by:
hi all, I have problem with SERIAL field type (or sequence functionality). I have table with three columns - ID, IDS, NAME. I want auto-increment IDS grouped by ID. Example: 1, 1, Ferdo 1, 2, John 2, 1, Martin 1, 3, Elvira
2
8693
by: alexs | last post by:
Chaps, I'm starting to play with db2 V9.1 and am writing a stored procedure to manage accounting records from oiur RADIUS server. I've got an XML aware table with an auto increment primary key, a few sql columns and an XML column. For every XML object I'm inserting, i'd lke to have an ID attribute that has the same value as the SQL...
2
5521
by: john | last post by:
Is it true that if I split my access database in backend and frontend and I implement custom auto increment for the ID fields, that my database is ready to be used in a multi-user environment? I found a zillion messages about auto increment and read some of them but it's confusing. Can someone point me to a simple custom auto increment example...
1
13362
by: rjames.clarke | last post by:
I am inserting a record in to a mysql database. I'd like to know the record number of that record. I use a index field which is auto-incremented. Is there any way to get a field value returned after insertion? I have been just running another query for the last record, but if someone does insertion a split second after the first...
0
4437
chumlyumly
by: chumlyumly | last post by:
Hello scripters - OS: Mac OSX Language: PHP w/ MySQL database I've created an insert page where a user inputs his info, which then goes to four different tables in a MySQL database. The tables are all linked with the field 'member_id', which is an auto-increment field in the parent table ('members'). I've been able to input multiple...
2
1596
by: skipwater | last post by:
I have two db each have the same table called manufacturers and same fields. db1 has a field called man_ID which is a auto increment field. This contains 90 records but over time the records have been added and deleted so the man_ID auto increment value is no longer in sequence. db2 is new with no records. What I need to do is insert the...
13
37547
by: BobLewiston | last post by:
Using Visual C# 2008 Express and SQL Server 2008 Express, I would like to insert new records into database "AdventureWorks", table "Person.Contact". To my surprise, this table's int-value identity column "ContactID" does not appear to be auto-increment. I don't know how to confirm for sure that this is so. (I have installed SQL Server...
0
7664
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7583
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7885
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7638
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7948
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5484
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3642
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
923
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.