Re: cannot assign non-composite value to a row variable

From: Alban Hertroys <dalroi(at)solfertje(dot)student(dot)utwente(dot)nl>
To: Eliot Gable <egable+pgsql-general(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: cannot assign non-composite value to a row variable
Date: 2010-06-04 14:07:35
Message-ID: C81A95C5-DA10-4246-A377-21E5781432D8@solfertje.student.utwente.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 supposed to 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't return 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!

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Rob Richardson 2010-06-04 15:03:52 How can I run an external program from a stored procedure?
Previous Message Eliot Gable 2010-06-04 13:37:43 cannot assign non-composite value to a row variable