错误:函数lastvar()不存在

时间:2012-07-06 15:50:08

标签: function triggers plpgsql postgresql-8.4

我遇到LASTVAL()功能问题。我有一个触发器:

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列,其SEQUENCE为DEFAULT值:

...
table_name_id bigint NOT NULL DEFAULT nextval('table_name_seq'::regclass),
...

1 个答案:

答案 0 :(得分:0)

你写了LASTVAR()而不是LASTVAL()( R 而不是 L )。