Search Postgresql Archives

Re: 9.6.1: INSERT with PK as serial

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxx','','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


--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux