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



---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
   (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])

Reply via email to