From: | Ed Loehr <eloehr(at)austin(dot)rr(dot)com> |
---|---|
To: | pggeneral <pgsql-general(at)postgresql(dot)org> |
Subject: | PL/pgSQL: "record not assigned yet" meaning? |
Date: | 2000-05-01 17:29:43 |
Message-ID: | 390DBF07.4CF94F0A@austin.rr.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
I have a plpgsql function that sets a column value on insert if it was not
supplied:
CREATE FUNCTION set_expense_unit()
RETURNS OPAQUE AS
'DECLARE
t RECORD;
BEGIN
if NEW.expense_unit_id isnull then
SELECT INTO t eu.*
FROM expense_unit eu, expense_type et
WHERE et.id = NEW.expense_type_id
AND et.expense_unit_id = eu.id;
NEW.expense_unit_id := t.id;
end if;
RETURN NEW;
END;'
LANGUAGE 'plpgsql';
DROP TRIGGER expense_insert_trigger ON expense;
CREATE TRIGGER expense_insert_trigger
BEFORE INSERT ON expense
FOR EACH ROW
EXECUTE PROCEDURE set_expense_unit();
Each time it runs, I get this error:
ERROR: record t is unassigned yet
Any ideas what this means?
Regards,
Ed Loehr
From | Date | Subject | |
---|---|---|---|
Next Message | Brett W. McCoy | 2000-05-01 17:40:56 | Re: GTK or TCL/TK ... what do you prefer ? (beginner) |
Previous Message | Brett W. McCoy | 2000-05-01 17:24:10 | Re: GTK or TCL/TK ... what do you prefer ? (beginner) |