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 <terencek@isd.canberra.edu.au>)
Список pgsql-sql
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 по дате отправления:

Предыдущее
От: "Richard Jones"
Дата:
Сообщение: Re: NOT and AND problem
Следующее
От: Gary Stainburn
Дата:
Сообщение: Re: unique value - trigger?