X-Original-To: pgsql-novice-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id AD68A3A63A5 for ; Mon, 13 Dec 2004 18:31:26 +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 21278-08 for ; Mon, 13 Dec 2004 18:31:17 +0000 (GMT) Received: from web51310.mail.yahoo.com (web51310.mail.yahoo.com [206.190.38.176]) by svr1.postgresql.org (Postfix) with SMTP id 597D93A6377 for ; Mon, 13 Dec 2004 18:31:17 +0000 (GMT) Received: (qmail 58581 invoked by uid 60001); 13 Dec 2004 18:31:14 -0000 Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; b=EhVckTIXplKW1b6RspqQ9fscUuDveTQVGQzsqp02sH/c3wN4am2HJpKPhZFEm4ETrtPa/Sn0NSRP0dZSrjM6gyx3Q6i4V1ut3/v7s62usQO3ypZ3lPfuUJB0/RoPfseqrqi8tFN1YZo45kXVDidMAEoMBchqZGZiz1TSflg/YX4= ; Message-ID: <20041213183113.58578.qmail@web51310.mail.yahoo.com> Received: from [65.218.182.242] by web51310.mail.yahoo.com via HTTP; Mon, 13 Dec 2004 10:31:13 PST Date: Mon, 13 Dec 2004 10:31:13 -0800 (PST) From: sarlav kumar Subject: Re: INSERT question To: pgsql-novice@postgresql.org In-Reply-To: <25641.1102956494@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-740725963-1102962673=:56488" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.586 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, HTML_20_30, HTML_MESSAGE X-Spam-Level: X-Archive-Number: 200412/85 X-Sequence-Number: 11662 --0-740725963-1102962673=:56488 Content-Type: text/plain; charset=us-ascii Thanks!! that worked!:) Tom Lane wrote:sarlav kumar 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 __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com --0-740725963-1102962673=:56488 Content-Type: text/html; charset=us-ascii
Thanks!! that worked!:)

Tom Lane <tgl@sss.pgh.pa.us> wrote:
sarlav kumar 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

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com --0-740725963-1102962673=:56488--