Dino Vliet wrote:

> MUCH better now....I did manage to get an insert into
> the table lessons with these adjustments...BUT now it
> seems the FOR LOOP didn't work because I only get 1
> record and expected that I would get 8 records due to
> the i variabele.
> 
> What could be wrong?
> 
> My code is now:
> 
> CREATE FUNCTION vulalles() RETURNS trigger AS '
> BEGIN
> FOR i in 0..7 LOOP
> INSERT INTO lessons (......)
> SELECT dayofweek,startdate + (i*7), enddate +
> (i*7),...;
> RETURN NEW;
> END LOOP;
> END;
> ' LANGUAGE plpgsql;

Is the 'RETURN NEW' statement supposed to be _BEFORE_ end loop?
To me, it looks like you are returning from the function
in the first loop turn.
/Njörn

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Reply via email to