Re: Mystery function error
От | Joe Conway |
---|---|
Тема | Re: Mystery function error |
Дата | |
Msg-id | 3F766FD5.3080001@joeconway.com обсуждение исходный текст |
Ответ на | Mystery function error ("Richard Sydney-Smith" <richard@ibisaustralia.com>) |
Список | pgsql-sql |
Richard Sydney-Smith wrote: > CREATE OR REPLACE FUNCTION public.locate(bpchar, bpchar) RETURNS > int4 AS ' -- search for the position of $2 in $1 > > declare srcstr alias for $1; searchstr alias for $2; > > begin return position(searchstr in srcstr); ' LANGUAGE 'plpgsql' > VOLATILE; You are missing the "end" keyword in there. Also, I'd think this function is IMMUTABLE not VOLATILE. CREATE OR REPLACE FUNCTION public.locate(bpchar, bpchar) RETURNS int4 AS ' -- search for the position of $2 in $1 declare srcstr alias for $1; searchstr alias for $2; begin return position(searchstr in srcstr); end; ' LANGUAGE 'plpgsql' IMMUTABLE; This could also be done as: CREATE OR REPLACE FUNCTION public.locate(bpchar, bpchar) RETURNS int4 AS ' select position($2 in $1) ' LANGUAGE 'sql'; HTH, Joe
В списке pgsql-sql по дате отправления: