Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XYgii-0005jW-RD for pgsql-sql@arkaria.postgresql.org; Mon, 29 Sep 2014 19:34:52 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XYgih-0003u4-O1 for pgsql-sql@arkaria.postgresql.org; Mon, 29 Sep 2014 19:34:51 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XYgig-0003tx-MQ for pgsql-sql@postgresql.org; Mon, 29 Sep 2014 19:34:50 +0000 Received: from sam.nabble.com ([216.139.236.26]) by makus.postgresql.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1XYgid-0005qZ-GV for pgsql-sql@postgresql.org; Mon, 29 Sep 2014 19:34:48 +0000 Received: from [192.168.236.26] (helo=sam.nabble.com) by sam.nabble.com with esmtp (Exim 4.72) (envelope-from ) id 1XYgic-0007yp-IM for pgsql-sql@postgresql.org; Mon, 29 Sep 2014 12:34:46 -0700 Date: Mon, 29 Sep 2014 12:34:46 -0700 (PDT) From: David G Johnston To: pgsql-sql@postgresql.org Message-ID: <1412019286556-5820984.post@n5.nabble.com> In-Reply-To: <1412018553142-5820980.post@n5.nabble.com> References: <1412018553142-5820980.post@n5.nabble.com> Subject: Re: Why data returned inside parentheses in for loop MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: 0.8 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org wujee wrote > Dear all, > > I have a simple query but the data returns inside parentheses, I think > there may be parameters that control this behavior but not sure what it > is. > > This is what I Have: > begin > for i in (select salary from salaries where employee_id > 1001) loop > dbms_output.put_line('i value: '||i); > end loop; > end; > > > And I got the result as the followings: > i value: (375402) > i value: (37539) > i value: (375394) > > > I do not want "(" and ")" in between the values, how should I do that? > > > Thanks, > Tina dbms_output.put_line('i value: ' || i.salary) "i" is a record type that has a single "salary" column. If it had two columns, say "SELECT name, salary FROM ..." you would have gotten (correct quoting not withstanding): i value: ('Name', 375402) pl/pgsql does not automatically reduce a single column to be a simple scalar - the "for rec_var in (query)" always results in rec_var being of type "record". David J. -- View this message in context: http://postgresql.1045698.n5.nabble.com/Why-data-returned-inside-parentheses-in-for-loop-tp5820980p5820984.html Sent from the PostgreSQL - sql mailing list archive at Nabble.com. -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql