There is no set variables in plpgsql. If you want to retrieve set of rows for futher manipulation either use a CURSOR or ARRAY:
declare
cur refcursor;
begin
open cur for
select * from table where ...;
loop
fetch cur into var1,var2...;
exit when not found;
end loop;
declare
arr offsite_batch[];
i int;
begin
select array(
select * from offsite_batch where ...
) into arr;
for i in 1..array_upper(arr,1)
loop
var1 := arr[i].id;
...
end loop;
Note that ARRAYs of composite type only appeared in 8.3.
I believe what you want to achieve can be done with simple query result looping:
for batch in (
select * from offsite_batch
where closed is NULL
order by age(opened) ASC
) loop
batch_found := true;
IF NOT unique THEN
RAISE WARNING 'more than one open batch found, closing...';
UPDATE offsite_batch
SET closed = now()
WHERE batch_id =
batch.id;
ELSE
latest_batch := batch;
unique := FALSE;
END IF;
end loop;
if not batch_found then
RAISE NOTICE 'creating new offsite batch';
...
end if;