From: | sarlav kumar <sarlavk(at)yahoo(dot)com> |
---|---|
To: | pgsqlperform <pgsql-performance(at)postgresql(dot)org> |
Subject: | Re: INSERT question |
Date: | 2004-12-13 18:33:08 |
Message-ID: | 20041213183308.68580.qmail@web51307.mail.yahoo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice pgsql-performance |
Thanks guys!! that worked!:)
Michael Adler <adler(at)pobox(dot)com> wrote:
On Mon, Dec 13, 2004 at 08:28:39AM -0800, sarlav kumar wrote:
> 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 FROM country WHERE send IS NOT NULL OR receive IS NOT NULL;
-Mike Adler
Bruno Wolff III <bruno(at)wolff(dot)to> wrote:
On Mon, Dec 13, 2004 at 08:28:39 -0800,
sarlav kumar wrote:
>
> 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);
>
You have to use a SELECT instead of the VAlues clause. Something like the
following should work:
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
;
---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo(at)postgresql(dot)org
---------------------------------
Do you Yahoo!?
All your favorites on one personal page Try My Yahoo!
From | Date | Subject | |
---|---|---|---|
Next Message | Nigel Pegus | 2004-12-13 18:43:06 | postgresql compile errors |
Previous Message | sarlav kumar | 2004-12-13 18:31:13 | Re: INSERT question |
From | Date | Subject | |
---|---|---|---|
Next Message | Josh Berkus | 2004-12-13 18:43:28 | Re: pg_restore taking 4 hours! |
Previous Message | Josh Berkus | 2004-12-13 18:31:40 | Re: Hardware purchase question |