Re: cannot assign non-composite value to a row variable - Mailing list pgsql-general

From Alban Hertroys
Subject Re: cannot assign non-composite value to a row variable
Date
Msg-id C81A95C5-DA10-4246-A377-21E5781432D8@solfertje.student.utwente.nl
Whole thread Raw
In response to cannot assign non-composite value to a row variable  (Eliot Gable <egable+pgsql-general@gmail.com>)
Responses Re: cannot assign non-composite value to a row variable  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
On 4 Jun 2010, at 15:37, Eliot Gable wrote:

> CREATE OR REPLACE blah ...
> ...
> DECLARE
>   myvariable complex1[];
>   mydatasource complex1;
>   myrowsource complex2[];
> ...
> BEGIN
> ...
>   -- The first way I tried to do it:
>   myvariable := array(
>     SELECT mydatasource FROM unnest(myrowsource)
>   );

I don't see what you're trying to do here; apparently myrowsource has a column named mydatasource, but how is PG
supposedto know which mydatasource you mean - the declared one or the one from mydatasource? The same goes for
myrowsource.
I'm pretty sure you have a naming conflict.

Or did you intend to write:
    myvariable := array(unnest(myrowsource));

That probably still doesn't work. I have no installation of 8.4 at my disposal atm, so I can't verify, but IIRC unnest
doesn'treturn an array, but something else. You probably need to cast it to the right type first. 

> Each of these gives the same error message:
>
> CONTEXT: ERROR
> CODE: 42804
> MESSAGE: cannot assign non-composite value to a row variable

Alban Hertroys

--
Screwing up is an excellent way to attach something to the ceiling.


!DSPAM:737,4c0908b610152006515388!



pgsql-general by date:

Previous
From: Eliot Gable
Date:
Subject: cannot assign non-composite value to a row variable
Next
From: "Rob Richardson"
Date:
Subject: How can I run an external program from a stored procedure?