Re: How to store multiple rows in array .

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: brahmesr <brahmam1234(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: How to store multiple rows in array .
Date: 2017-11-20 03:48:04
Message-ID: 14909.1511149684@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

brahmesr <brahmam1234(at)gmail(dot)com> 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Cory Tucker 2017-11-20 06:16:48 Query Using Massive Temp Space
Previous Message brahmesr 2017-11-20 02:12:18 Re: How to store multiple rows in array .