Hi,

I have compiled postgres 7.0.3 from sources and installed on
our server. I wanted to try out the feature of triggers in
postgres. Hence I took one example from the manual. Here it
is :

---------------------------------------
drop function emp_stamp();
drop trigger emp_stamp on emp;
drop table emp;

create table emp (
        empname         text,
        salary          int4,
        last_date       datetime,
        last_user       name);

CREATE FUNCTION emp_stamp () RETURNS OPAQUE AS '
BEGIN
        -- Check that empname and salary are given
        IF new.empname ISNULL THEN
                RAISE EXCEPTION ''empname cannot be NULL value'';
        END IF;
        IF NEW.salary ISNULL THEN
                RAISE EXCEPTION ''% cannot have NULL salary'', NEW.empname;
        END IF;

        -- Who works for us when she must pay for ?
        IF new.salary < 0 THEN
                RAISE EXCEPTION ''% cannot have a negative salary'',new.empname;
        END IF;

        -- Remember who changed the payroll when
        NEW.last_date := ''now'';
        NEW.last_user := getpgusername();
        RETURN NEW;
END;
' LANGUAGE 'plpgsql';

CREATE TRIGGER emp_stamp BEFORE INSERT OR UPDATE ON emp FOR
EACH ROW EXECUTE PROCEDURE emp_stamp();
---------------------------------------

I have added support of procedural language 'plpgsql' in
postgres system table pg_language ( This help I got from
ilug-goa mailing list ). Now when I try to insert a record
in the emp table :

insert into emp(empname, salary) values( 'test', 1000 );

from psql I get the following error :

psql:rec.sql:1:ERROR:frmgr_info:function 0:cache lookup failed

Anybody using postgres on this list ?
Can u help me to find out the cause of this error ?

Thanks in advance.

Warm Regards


-- 
Rajesh Fowkar
V. S. DEMPO & CO. LTD., PANAJI-GOA

Email ID : [EMAIL PROTECTED], [EMAIL PROTECTED]
Web Site : http://www.dempos.com


_______________________________________________
linux-india-help mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/linux-india-help

Reply via email to