Обсуждение: plpgsql assigning RECORD := RECORD

Поиск
Список
Период
Сортировка

plpgsql assigning RECORD := RECORD

От
bsides2@hotmail.com (MK)
Дата:
Hi all,

I have a question regarding the RECORD type in plpgsql functions.

How do I assign a RECORD variable to another RECORD variable?

For example,

DECLARE
rs1 RECORD;
rs2 RECORD;
BEGIN

FOR rs1 IN SELECT * FROM mytable LOOP

  rs2 := rs1; --IS THIS POSSIBLE!?
END LOOP;
END;

When executing my function I  receive 'syntax error at or near "rs2"'.
So, obviously my syntax is not correct. Is there another way to
perform this?

In my loop I need to have access to the PREVIOUS record. There are A
LOT of fields being selected so storing each in its own variable is
not a desirable solution.

Any ides?

Thanks in advance

Re: plpgsql assigning RECORD := RECORD

От
Tom Lane
Дата:
bsides2@hotmail.com (MK) writes:
> How do I assign a RECORD variable to another RECORD variable?

You can do that in 8.0 beta, but not in prior releases.

            regards, tom lane