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

From Dino Vliet
Subject error: insert has more expressions than target column
Date
Msg-id 20040907132453.8923.qmail@web40109.mail.yahoo.com
Whole thread Raw
Responses Re: error: insert has more expressions than target column
List pgsql-general
Hi there,
I want to put a number of records (variable number
depending on a attribute of a table) into a certain
table with a trigger statement.

I have created the follwing trigger:

CREATE FUNCTION vullalles() RETURNS trigger AS '
BEGIN
FOR i in 0..7 LOOP
INSERT INTO lessons (select
dayofweek,startdate,endate,startime,endtime,teacher,location,roomnr
from courseschedule);
startdate := startdate + i*7;
EXECUTE startdate;
RETURN NEW;
END LOOP;
END;
' LANGUAGE plpgsql;

When I insert a record into courseschedule, I get the
following error:
insert has more expressions than target column

WHAT AM I DOING WRONG?

The function should insert 8 records into lessons when
I insert one record in courseschedule. Now it is done
with a hardcoded for loop but eventually it should be
done based on a attribute in courseschedule.

How can I fix this?

I'm using postgresql 7.4.3 under Freebsd.




_______________________________
Do you Yahoo!?
Win 1 of 4,000 free domain names from Yahoo! Enter now.
http://promotions.yahoo.com/goldrush

pgsql-general by date:

Previous
From: Alex Soto
Date:
Subject: Re: Help supressing NOTICE messages
Next
From: Valerie Schneider DSI/DEV
Date:
Subject: Pb with ecpg and include file on PG 8.0.0