Mystery function error - Mailing list pgsql-sql

From Richard Sydney-Smith
Subject Mystery function error
Date
Msg-id 000c01c38572$73c03c50$251a32d2@athlon2000
Whole thread Raw
Responses Re: Mystery function error
Re: Mystery function error
Re: Mystery function error
List 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 by date:

Previous
From: Bertrand Petit
Date:
Subject: Re: pg_class.relpages
Next
From: Joe Conway
Date:
Subject: Re: Mystery function error