×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

error message

error message

error message

(OP)
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.

RE: error message

(OP)
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
);

RE: error message

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:

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

Or this:

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 http://www.postgresql.org/idocs/index.php?sql-insert.html)

-------------------------------------------

"Now, this might cause some discomfort..."
(http://www.wired.com/news/politics/0,1283,51274,00.html)

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close