Mystery function error

From: "Richard Sydney-Smith" <richard(at)ibisaustralia(dot)com>
To: <pgsql-sql(at)postgresql(dot)org>
Subject: Mystery function error
Date: 2003-09-28 03:39:19
Message-ID: 000c01c38572$73c03c50$251a32d2@athlon2000
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Joe Conway 2003-09-28 05:21:25 Re: Mystery function error
Previous Message Jan Wieck 2003-09-28 03:33:06 Re: [SQL] plpgsql doesn't coerce boolean expressions to