Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g2JWC-000734-L8 for pgsql-general@arkaria.postgresql.org; Tue, 18 Sep 2018 17:10:32 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1g2JWB-0004cR-91 for pgsql-general@arkaria.postgresql.org; Tue, 18 Sep 2018 17:10:31 +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.89) (envelope-from ) id 1g2JWA-0004cJ-US for pgsql-general@lists.postgresql.org; Tue, 18 Sep 2018 17:10:31 +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 1g2JW8-00086K-Jz for pgsql-general@postgresql.org; Tue, 18 Sep 2018 17:10:29 +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 w8IHAQqA016267; Tue, 18 Sep 2018 13:10:26 -0400 From: Tom Lane To: marcelo cc: "pgsql-general@postgresql.org" Subject: Re: Select into table%ROWTYPE failed In-reply-to: <101ff717-5edc-b671-1903-098ae1f74bd3@gmail.com> References: <101ff717-5edc-b671-1903-098ae1f74bd3@gmail.com> Comments: In-reply-to marcelo message dated "Tue, 18 Sep 2018 13:14:11 -0300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <16265.1537290626.1@sss.pgh.pa.us> Date: Tue, 18 Sep 2018 13:10:26 -0400 Message-ID: <16266.1537290626@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk marcelo writes: > What was wrong in the first approach? plpgsql's "SELECT INTO" expects a one-for-one match between the output columns of the SELECT and the columns of the INTO destination. So I'd expect something like this to work: DECLARE ranger billnumberrange%ROWTYPE; BEGIN SELECT * FROM billnumberrange WHERE ... INTO ranger; Your example clearly wasn't selecting all the columns, and it wasn't clear whether you paid any attention to column ordering; but both of those matter. regards, tom lane