Re: parse error for function def
От
Stephan Szabo
Тема
Re: parse error for function def
Дата
Msg-id
20030717083541.W59122-100000@megazone.bigpanda.com
Ответ на
parse error for function def (Terence Kearns)
Список
Дерево обсуждения
parse error for function def Terence Kearns <terencek@isd.canberra.edu.au>
Re: parse error for function def Stephan Szabo <sszabo@megazone.bigpanda.com>
Re: parse error for function def Jonathan Gardner <jgardner@jonathangardner.net>
Re: parse error for function def Dmitry Tkach <dmitry@openratings.com>
Re: parse error for function def greg@turnstep.com
On Thu, 17 Jul 2003, Terence Kearns wrote: > CREATE FUNCTION base.fn_fkey_check(text, text, int4) RETURNS bool AS > 'DECLARE > BEGIN > RETURN (SELECT count($1) FROM $2 where $1 = $3)::bool; > END;' > LANGUAGE 'sql'; > > produces this error > ERROR: parser: parse error at or near "RETURN" at character 20 > > I'm trying to create a function to use on a trigger to check reference > to views since pg does not support foreign keys referencing views. As others have said, the function above is much closer to a plpgsql function, excepting that you still couldn't use $2 in the from clause without execute I believe. In addition, the above isn't going to simulate a foreign key unless the view is entirely static (if it were that simple, we'd have implemented it) since changes to the view's base table(s) could make the constraint be invalid as well.
В списке pgsql-sql по дате отправления