Re: Select into table%ROWTYPE failed

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: marcelo <marcelo(dot)nicolet(at)gmail(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Select into table%ROWTYPE failed
Date: 2018-09-18 17:10:26
Message-ID: 16266.1537290626@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

marcelo <marcelo(dot)nicolet(at)gmail(dot)com> 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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Stephen Frost 2018-09-18 17:14:30 Re: Code of Conduct
Previous Message Chris Travers 2018-09-18 17:08:09 Re: Code of Conduct