ROWTYPE initialization question

From: Alban Hertroys <alban(at)magproductions(dot)nl>
To: Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: ROWTYPE initialization question
Date: 2006-11-09 15:37:23
Message-ID: 45534B33.8060209@magproductions.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

'lo list,

I have a plpgsql SP where I loop through a cursor. I have an internal
variable that keeps the previous row, so that I can compare it with the
current row in the cursor.
Like so;

DECLARE
current table%ROWTYPE;
previous table%ROWTYPE;
BEGIN
LOOP
FETCH tableCur INTO current;

-- Do stuff

But, in this loop I need to compare the previous row to the current one.
To do that I need to know whether a row was assigned to 'previous', or
there'll be very little to compare (if it doesn't throw an error).
How do I check for that?

I guess it would be like this, but I'd like to be sure.

IF previous IS NOT NULL
THEN
-- Compare previous and current column values
END IF

previous := current;
END LOOP;
END;

Thanks in advance,
--
Alban Hertroys
alban(at)magproductions(dot)nl

magproductions b.v.

T: ++31(0)534346874
F: ++31(0)534346876
M:
I: www.magproductions.nl
A: Postbus 416
7500 AK Enschede

// Integrate Your World //

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Andrus 2006-11-09 15:47:42 Re: Why overlaps is not working
Previous Message Alvaro Herrera 2006-11-09 15:34:55 Re: authentication question