The tuple structure of a not-yet-assigned record is indeterminate.

From: M L <novemberox(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: The tuple structure of a not-yet-assigned record is indeterminate.
Date: 2009-03-22 22:47:48
Message-ID: c11212cc0903221547h50a5adfan6c59e1895bb195b6@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi there, i'm new to postgres. I want to create view when adding new row. So
what i've got:

CREATE OR REPLACE FUNCTION add_view() RETURNS trigger AS $$
DECLARE
someint integer;
BEGIN
RAISE NOTICE 'dodajesz nowa lige %', NEW.id;
someint := NEW.id;
RAISE NOTICE 'dodajesz nowa lige %', someint;
CREATE VIEW tabelka AS SELECT * FROM t_matches.someint;
RETURN NULL;
END;
$$ language plpgsql;

CREATE TRIGGER league AFTER insert ON t_leagues FOR STATEMENT EXECUTE
PROCEDURE add_view();

Then in psql I made an query and got error:

league=# INSERT INTO t_leagues (name) VALUES('3liga');
ERROR: record "new" is not assigned yet
DETAIL: The tuple structure of a not-yet-assigned record is indeterminate.
CONTEXT: PL/pgSQL function "add_view" line 4 at RAISE

Whats wrong, I supposed that id is not reserverd at the moment, so what can
I do?

And here is some infos about table

league=# \d t_leagues
Table "public.t_leagues"
Column | Type |
Modifiers
------------+-----------------------+--------------------------------------------------------
id | integer | not null default
nextval('t_leagues_id_seq'::regclass)
name | character varying(20) | not null
data_start | date |
data_end | date |
awans | smallint | not null default 0
baraz | smallint | not null default 0
spadek | smallint | not null default 0
Indexes:
"t_leagues_pkey" PRIMARY KEY, btree (id)
Triggers:
league AFTER INSERT ON t_leagues FOR EACH STATEMENT EXECUTE PROCEDURE
add_view()

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Craig Ringer 2009-03-23 01:11:18 Re: The tuple structure of a not-yet-assigned record is indeterminate.
Previous Message Scott Marlowe 2009-03-22 19:36:55 Re: text column constraint, newbie question