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

From Richard Huxton
Subject Re: error: insert has more expressions than target column
Date
Msg-id 413DBEA7.9050905@archonet.com
Whole thread Raw
In response to error: insert has more expressions than target column  (Dino Vliet <dino_vliet@yahoo.com>)
Responses Re: error: insert has more expressions than target column  (Dino Vliet <dino_vliet@yahoo.com>)
List pgsql-general
Dino Vliet wrote:
> 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);

Try it without the brackets around select, or put the column-names in
brackets before it.

> startdate := startdate + i*7;
> EXECUTE startdate;

Not sure what this is supposed to be doing. The EXECUTE is redundant.

> RETURN NEW;
> END LOOP;
> END;
> ' LANGUAGE plpgsql;

--
   Richard Huxton
   Archonet Ltd

pgsql-general by date:

Previous
From: David Garamond
Date:
Subject: Dumping pg_shadow and pg_database as SQL using pg_dump
Next
From: Dino Vliet
Date:
Subject: Re: error: insert has more expressions than target column