PL/pgSQL: "record not assigned yet" meaning?
| От | Ed Loehr |
|---|---|
| Тема | PL/pgSQL: "record not assigned yet" meaning? |
| Дата | |
| Msg-id | 390DBF07.4CF94F0A@austin.rr.com обсуждение исходный текст |
| Ответы |
Re: PL/pgSQL: "record not assigned yet" meaning?
|
| Список | 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
В списке pgsql-general по дате отправления: