Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

error message

Status
Not open for further replies.

tanveer91

Programmer
Nov 13, 2001
31
GB
hi all,

i'm new(ish) to postgres.......i am trying to insert a record in a database but it keeps returning the following error message:

ERROR: parser: parse error at or near "SELECT"

to insert i have used the following command at psql prompt:

INSERT INTO orders VALUES (1,'Mondeo','Red','YS81APB');

Thanks for your help.
 
Hi rycamor,

This is the table structure i'm using:

create table orders (
o_id int4 default nextval('orders_o_id_seq'::text) not null,
omodel character varying (20),
ocolour character varying (20),
oforder character varying (5),
oodate date,
oordref character varying (20),
osman int4 references users(uid),
ochassis character varying (17),
oprivstate int4 references states(sid),
opubstate int4 references states(sid),
ocompany int4 references dealers(did) not null,
odept character (1) references depts(pid) not null,
ocustomer int4 references customers(cid) not null,
olocation int4 references locations(lid) not null,
ostockno character varying (6),
oregno character varying (12),
odeldate date,
oprivnotes text,
opubnotes text,
ojobcard int4, -- job number instead of yes/no
ovista character varying(20), -- unknown contents
);
 
You are trying to insert 4 columns into a 21-column table. If you don't specify 21 columns in your INSERT, you have to explicitly specify which columns you are inserting:

Either do this:

Code:
INSERT INTO orders VALUES (1,'Mondeo','Red','YS81APB','','','','','','','','','','','','','','','','','');

Or this:

Code:
INSERT INTO orders(o_id,omodel,ocolour,oforder) VALUES (1,'Mondeo','Red','YS81APB');

Otherwise, how will the SQL parser "know" which columns you are choosing to insert? (See -------------------------------------------

"Now, this might cause some discomfort..."
(
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top