From: | Penguin <Mail(at)dempos(dot)com> |
---|---|
To: | PostgreSQL General Mailing List <pgsql-general(at)postgresql(dot)org> |
Subject: | psql , stored procedure, triggers and errors |
Date: | 2001-06-05 08:57:25 |
Message-ID: | 20010605142725.A10865@ho.dempos.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi,
I am new to this mailing list. Sorry if my question sounds silly.
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. 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
Can anybody 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 : Mail(at)dempos(dot)com, rfowkar(at)yahoo(dot)com
Web Site : http://www.dempos.com
From | Date | Subject | |
---|---|---|---|
Next Message | Matteo Centenaro | 2001-06-05 11:17:24 | problem with Pl/Pgsql function |
Previous Message | Igor | 2001-06-05 08:10:18 | How to Alter tables with ARRAY? Help PLease |