Re: PL/pgsql insert into failing even with returning into clause - Mailing list pgsql-novice

From Tom Lane
Subject Re: PL/pgsql insert into failing even with returning into clause
Date
Msg-id 18199.1587083950@sss.pgh.pa.us
Whole thread Raw
In response to PL/pgsql insert into failing even with returning into clause  (Mark Bannister <mark@injection-moldings.com>)
Responses Re: PL/pgsql insert into failing even with returning into clause  (Mark Bannister <mark@injection-moldings.com>)
List pgsql-novice
Mark Bannister <mark@injection-moldings.com> writes:
> I have a simple insert into query in a PL/pgsql function.  I have a
> returning into clause.
>  I have tried it multiple ways but it always gives me the "query has no
> destination for result data" error.

It looks like you forgot to include "INTO plpgsql-result-variable"
in the last UPDATE RETURNING in the function.  You do have that
in the earlier one, maybe you just got confused about which one
the system was complaining about?

> *Desired version:*

> INSERT  INTO __formuilist  (formidfkey,uiname,mastertablelistxref_fkey)
>          VALUES(_formidfkey,_uiname, _mastertablelistxref_fkey)
>          RETURNING ROW
>           INTO   formlistrow ;

I believe the easiest way to accomplish that is something like

INSERT ... RETURNING __formuilist.* INTO composite_variable

where composite_variable could be declared RECORD, or given
the table's named rowtype.

            regards, tom lane



pgsql-novice by date:

Previous
From: Mark Bannister
Date:
Subject: PL/pgsql insert into failing even with returning into clause
Next
From: Mark Bannister
Date:
Subject: Re: PL/pgsql insert into failing even with returning into clause