0
我遇到了LASTVAL()函數的問題。我有一個觸發器:錯誤:函數lastvar()不存在
CREATE OR REPLACE FUNCTION schema_name.function_name() RETURNS TRIGGER AS
$BODY$
DECLARE
registry_id bigint;
BEGIN
INSERT INTO schema_name.table_name(column1, column2) VALUES (value1, value2);
SELECT LASTVAR() INTO registry_id;
...
當觸發器被激發我的錯誤:
ERROR: function lastvar() does not exist
LINE 1: SELECT LASTVAR()
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
QUERY: SELECT LASTVAR()
CONTEXT: PL/pgSQL function "function_name" line 5 at SQL statement
表中有一個序列作爲默認值的PK列:
...
table_name_id bigint NOT NULL DEFAULT nextval('table_name_seq'::regclass),
...
謝謝你,我正在尋找15分鐘爲什麼這個函數確實存在。我不敢相信我這樣做是錯的。 – hschimpf 2012-07-06 15:57:37