Обсуждение: Syntax check for functions?

Поиск
Список
Период
Сортировка

Syntax check for functions?

От
Andreas Schlegel
Дата:
Hi,

is there any chance to make a syntax check of a function/trigger before
creating it.
I just wrote my first function and trigger in Postgres an dit won't work :-(

I get the error: "fmgr_info: function 541860: cache lookup failed"

May be somebody may have a look on the function and see the error(s).

Is the use of "length(new.extid) = 0" right or do I have to ask "is null"?

Greetings,
Andreas



CREATE FUNCTION trigger_insert_custno_ext()
RETURNS opaque
AS 'BEGIN
     IF length(new.extid) = 0
     THEN new.extid = new.custno; -- put custno into extid column
     END IF;
     RETURN new;
   END;'
LANGUAGE 'plpgsql';


CREATE TRIGGER trigger_custno_ext
BEFORE INSERT OR UPDATE
ON tCustomer
FOR EACH ROW
EXECUTE PROCEDURE trigger_insert_custno_ext();


Re: Syntax check for functions?

От
Stephane Bortzmeyer
Дата:
On Thu, Jul 11, 2002 at 07:23:23PM +0200,
 Andreas Schlegel <schlegel@software.b.uunet.de> wrote
 a message of 37 lines which said:

> I just wrote my first function and trigger in Postgres an dit won't work :-(
>
> I get the error: "fmgr_info: function 541860: cache lookup failed"

It is not a syntax error. It is simply because the binding between the
trigger and the function is done once and stays in the cache after
(you probably changed the function after the trigger). You have to
drop the trigger and recreate it.