Search Postgresql Archives

Strugging with NEW and OLD records.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I am a newbie to the stored proc. game and this is eating my brain.

> CREATE TABLE name(first VARCHAR(32) NULL,last VARCHAR(32) NULL, extra VARCHAR(32) NULL );

> CREATE OR REPLACE FUNCTION update_name() RETURNS opaque AS '
    DECLARE
    BEGIN
   
        NEW.extra:=NEW.first;
        RETURN NEW;

    END;
' LANGUAGE 'plpgsql';

> CREATE TRIGGER update_name_extra BEFORE INSERT
ON name
EXECUTE PROCEDURE update_name();

> INSERT INTO name(first,last) VALUES('script','head');
ERROR:  record "new" is not assigned yet
DETAIL:  The tuple structure of a not-yet-assigned record is indeterminate.
CONTEXT:  PL/pgSQL function "update_name" line 4 at assignment

What am I doing wrong?

ScriptHead

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux