Re: error: insert has more expressions than target column - Mailing list pgsql-general

From Björn Lundin
Subject Re: error: insert has more expressions than target column
Date
Msg-id chl4q8$13c6$1@news.hub.org
Whole thread Raw
In response to Re: error: insert has more expressions than target column  (Richard Huxton <dev@archonet.com>)
List pgsql-general
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

pgsql-general by date:

Previous
From: "Katsaros Kwn/nos"
Date:
Subject: stringToNode() for plan nodes...
Next
From: Dennis Gearon
Date:
Subject: Release of 8.0.0