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