Re: error: insert has more expressions than target column

From: Björn Lundin <bnl(at)tiscali(dot)se>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: error: insert has more expressions than target column
Date: 2004-09-07 20:14:02
Message-ID: chl4q8$13c6$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Manfred Koizar 2004-09-07 20:29:54 Re: sequences in schemas
Previous Message Tom Lane 2004-09-07 19:14:28 Re: Restoring dump of multiuser databases