pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Richard Sydney-Smith <richard@ibisaustralia.com>
To: pgsql-sql@postgresql.org
Subject: Mystery function error
Date: Sun, 28 Sep 2003 11:39:19 +0800
Message-ID: <000c01c38572$73c03c50$251a32d2@athlon2000> (raw)

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

view thread (10+ messages)  latest in thread

Message-ID: <000c01c38572$73c03c50$251a32d2@athlon2000>
Permalink:  ../000c01c38572$73c03c50$251a32d2@athlon2000/
Also on:    postgresql.org/message-id/000c01c38572$73c03c50$251a32d2@athlon2000

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: richard@ibisaustralia.com
  Subject: Re: Mystery function error
  In-Reply-To: <000c01c38572$73c03c50$251a32d2@athlon2000>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox