Re: INSERT question

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: sarlav kumar <sarlavk(at)yahoo(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: INSERT question
Date: 2004-12-13 16:48:14
Message-ID: 25641.1102956494@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice pgsql-performance

sarlav kumar <sarlavk(at)yahoo(dot)com> writes:
> Is there a way to write the INSERT as follows?

> INSERT into merchant_buyer_country (merchant_id,country,enabled,group_id) values (1203,
> (SELECT code FROM country WHERE send IS NOT NULL OR receive IS NOT NULL), 'true',1);

> I tried this, but I get the following problem:
> ERROR: More than one tuple returned by a subselect used as an expression.

INSERT into merchant_buyer_country (merchant_id,country,enabled,group_id)
SELECT 1203, code, 'true', 1 FROM country
WHERE send IS NOT NULL OR receive IS NOT NULL;

regards, tom lane

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Bruno Wolff III 2004-12-13 16:49:52 Re: INSERT question
Previous Message sarlav kumar 2004-12-13 16:28:39 INSERT question

Browse pgsql-performance by date

  From Date Subject
Next Message Bruno Wolff III 2004-12-13 16:49:52 Re: INSERT question
Previous Message Vivek Khera 2004-12-13 16:47:34 Re: Alternatives to Dell?