Mystery function error

Поиск
Список
Период
Сортировка
От Richard Sydney-Smith
Тема Mystery function error
Дата
Msg-id 000c01c38572$73c03c50$251a32d2@athlon2000
обсуждение исходный текст
Ответы Re: Mystery function error
Re: Mystery function error
Re: Mystery function error
Список pgsql-sql
As I am converting from Sybase I wanted to create a function which would replicate the behaviour of the sybase "Locate" command.
 
The goal is to have
 
locate( stra, strb) = position(strb in stra)
 
where "position" is the standard postgres function for the index position of string "A" in string "B"
 
My attempt at a function to do this task returns the error message
 
ERROR: parse error at or near '"'   
 
I can not see why.... and have attached the simple function.
 
------------------------------------------------------------------------------------------------------
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;
-------------------------------------------------------------------------------------------------------------
 
Thanks very much
 
Richard

В списке pgsql-sql по дате отправления:

Предыдущее
От: Bertrand Petit
Дата:
Сообщение: Re: pg_class.relpages
Следующее
От: Joe Conway
Дата:
Сообщение: Re: Mystery function error