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

Поиск
Список
Период
Сортировка
От M L
Тема The tuple structure of a not-yet-assigned record is indeterminate.
Дата
Msg-id c11212cc0903221547h50a5adfan6c59e1895bb195b6@mail.gmail.com
обсуждение исходный текст
Ответы Re: The tuple structure of a not-yet-assigned record is indeterminate.  (Craig Ringer <craig@postnewspapers.com.au>)
Список 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()



В списке pgsql-general по дате отправления:

Предыдущее
От: Scott Marlowe
Дата:
Сообщение: Re: text column constraint, newbie question
Следующее
От: Craig Ringer
Дата:
Сообщение: Re: The tuple structure of a not-yet-assigned record is indeterminate.