Re: [GENERAL] 9.6.1: INSERT with PK as serial - Mailing list pgsql-general

From Rich Shepard
Subject Re: [GENERAL] 9.6.1: INSERT with PK as serial
Date
Msg-id alpine.LNX.2.11.1701161620210.18553@localhost
Whole thread Raw
In response to Re: [GENERAL] 9.6.1: INSERT with PK as serial  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: [GENERAL] 9.6.1: INSERT with PK as serial
Re: [GENERAL] 9.6.1: INSERT with PK as serial
Re: [GENERAL] 9.6.1: INSERT with PK as serial
List pgsql-general
On Mon, 16 Jan 2017, Tom Lane wrote:

> It looks like something deleted the quote marks.  How are you entering
> this SQL command, exactly?

Tom,

   I noticed that, too. Here's the first line:

INSERT INTO companies

('comp_id','comp_name','addr1','addr2','city','comp_state','postcode','country','phone','fax','e_mail','url','industry','status','comment')
VALUES
(1,'AG Spray Inc.',' ','PO Box

12129','Salem','OR','97309-0129','USA','503-371-7907','888-273-0937','info@agsprayinc.com','','Chemicals','Opportunity',''),

   Other than the comp_id PK column each column's data type is a delimited
string:

CREATE TABLE companies (
   comp_id serial PRIMARY KEY,
   comp_name varchar(64) NOT NULL,
   addr1 varchar(64),
   addr2 varchar(64),
   city varchar(16),
   comp_state char(2),
   postcode varchar(9),
   country varchar(12) DEFAULT 'USA' NOT NULL,
   phone varchar(10),
   fax varchar(10),
   e_mail varchar(64),
   url varchar(64),
   industry varchar(24) NOT NULL
     CONSTRAINT invalid_industry
     CHECK (industry in ('Agriculture', 'Business, other', 'Chemicals',
     'Energy', 'Law', 'Manufacturing', 'Mining', 'Municipalities',
     'Ports/Marine Services', 'Transportation')),
   status varchar(20) NOT NULL
     CONSTRAINT invalid_status
     CHECK (status in ('Client', 'Proposal submitted', 'Prospect',
     'Referral', 'Opportunity', 'No further contact')),
   comment text
);

> Also, you can't just write double commas to leave out a item in the
> value list.  You could write DEFAULT there, ie

   I tried with ,, and ,'', and ,' '. Same error each time. Also, listing
each column name does not fix the problem.

Thanks,

Rich


pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: [GENERAL] 9.6.1: INSERT with PK as serial
Next
From: John R Pierce
Date:
Subject: Re: [GENERAL] 9.6.1: INSERT with PK as serial