Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eGd49-0005tQ-Ua for pgsql-general@arkaria.postgresql.org; Mon, 20 Nov 2017 03:48:14 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1eGd49-0003ya-1N for pgsql-general@arkaria.postgresql.org; Mon, 20 Nov 2017 03:48:13 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eGd46-0003y4-QM for pgsql-general@postgresql.org; Mon, 20 Nov 2017 03:48:10 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eGd42-00079E-5s for pgsql-general@postgresql.org; Mon, 20 Nov 2017 03:48:09 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id vAK3m45F014910; Sun, 19 Nov 2017 22:48:04 -0500 From: Tom Lane To: brahmesr cc: pgsql-general@postgresql.org Subject: Re: How to store multiple rows in array . In-reply-to: <1511143938357-0.post@n3.nabble.com> References: <11642.1511116381@sss.pgh.pa.us> <1511143938357-0.post@n3.nabble.com> Comments: In-reply-to brahmesr message dated "Sun, 19 Nov 2017 19:12:18 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <14908.1511149684.1@sss.pgh.pa.us> Date: Sun, 19 Nov 2017 22:48:04 -0500 Message-ID: <14909.1511149684@sss.pgh.pa.us> List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-general Precedence: bulk Sender: pgsql-general-owner@postgresql.org brahmesr writes: > SELECT ARRAY (SELECT ROW (COL1,COL2, COUNT(*) *AS txn_cnt* ):: > ap.validate_crtr_line_items$inv_lines_rt FROM Distinct_Records GROUP BY > COL1, COL2 HAVING COUNT(*) > 1) INTO L_INV_LINES; > ERROR: syntax error at or near "AS" > LINE 73: COL1,COL2, COUNT(*) AS txn_cnt... > Why "AS" is throwing an error ? "AS" is part of SELECT-list syntax, not ROW(...) syntax. Even if it were allowed in ROW(), it would be totally pointless in this context, because when you cast the ROW() result to the ap.validate_crtr_line_items$inv_lines_rt composite type, that type is what determines the column names. regards, tom lane -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general