PLPGSQL problem

From: "nsrini" <nsrini(at)broadgateindia(dot)com>
To: <pgsql-general(at)postgresql(dot)org>
Subject: PLPGSQL problem
Date: 2002-09-26 12:57:45
Message-ID: 002501c2655c$6546a380$1e2236ca@btsnode1
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi there,
I am not sure whether this is the right mail.

I am having problem with PLPGSQL.
I have set up the langucage in pg_language table as mentioned in the docs.
I am able to create functions and triggers. But when I insert a record into the table It shows an error as shown below
ERROR: fmgr_info: function 0: cache lookup failed

Details about the table,function and trigger and the query I ran

drop table emp1;

CREATE TABLE emp1 (
empname text,
salary int4,
last_date datetime,
last_user name);

drop function emp_stamp();

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';

drop trigger emp_stamp;
CREATE TRIGGER emp_stamp BEFORE INSERT OR UPDATE ON emp1 FOR EACH ROW
EXECUTE PROCEDURE emp_stamp();

gs=# insert into emp1 values('emp',43,now(),'');

Regards,
Srini

Browse pgsql-general by date

  From Date Subject
Next Message Robert Treat 2002-09-26 13:30:39 Re: Nicer dump files?
Previous Message Andriy Tkachuk 2002-09-26 12:11:55 query speed depends on lifetime of frozen db?