X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 5653E3A6476 for ; Mon, 13 Dec 2004 18:33:21 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 21496-09 for ; Mon, 13 Dec 2004 18:33:15 +0000 (GMT) Received: from web51307.mail.yahoo.com (web51307.mail.yahoo.com [206.190.38.173]) by svr1.postgresql.org (Postfix) with SMTP id 4597B3A638C for ; Mon, 13 Dec 2004 18:33:13 +0000 (GMT) Received: (qmail 68584 invoked by uid 60001); 13 Dec 2004 18:33:08 -0000 Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; b=hGA03m5zO0KRjqvUgGEuWhoUqsUVMc1QfTBYhkK7rhscgx1CLK5N225LkvyG4t7Ttz9/ap3Kh/8SwD0+EczczY0t5cOskknsh3jSz5TsNAyoCKenf5n2XD1cJHSB5KNhRdoKuQKZCVDtz3S5Q+iZiB31KMBekrqqbmxhA1QEL+s= ; Message-ID: <20041213183308.68580.qmail@web51307.mail.yahoo.com> Received: from [65.218.182.242] by web51307.mail.yahoo.com via HTTP; Mon, 13 Dec 2004 10:33:08 PST Date: Mon, 13 Dec 2004 10:33:08 -0800 (PST) From: sarlav kumar Subject: Re: INSERT question To: pgsqlperform In-Reply-To: <20041213164952.GC546@wolff.to> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-1073146567-1102962788=:67060" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.613 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, HTML_20_30, HTML_MESSAGE X-Spam-Level: X-Archive-Number: 200412/167 X-Sequence-Number: 9542 --0-1073146567-1102962788=:67060 Content-Type: text/plain; charset=us-ascii Thanks guys!! that worked!:) Michael Adler 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 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@postgresql.org --------------------------------- Do you Yahoo!? All your favorites on one personal page – Try My Yahoo! --0-1073146567-1102962788=:67060 Content-Type: text/html; charset=us-ascii
Thanks guys!! that worked!:)

Michael Adler <adler@pobox.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@wolff.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@postgresql.org


Do you Yahoo!?
All your favorites on one personal page – Try My Yahoo! --0-1073146567-1102962788=:67060--