X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id DEF89D1B4E3 for ; Sun, 28 Sep 2003 03:39:41 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 67023-01 for ; Sun, 28 Sep 2003 00:39:30 -0300 (ADT) Received: from server146.hostingrevolution.com (unknown [64.21.143.245]) by svr1.postgresql.org (Postfix) with ESMTP id 05F55D1B527 for ; Sun, 28 Sep 2003 00:39:30 -0300 (ADT) Received: from 037.b.001.pth.iprimus.net.au ([210.50.26.37] helo=athlon2000) by server146.hostingrevolution.com with smtp (Exim 4.23) id 1A3SPT-0005aI-Ck for pgsql-sql@postgresql.org; Sat, 27 Sep 2003 22:39:26 -0500 Message-ID: <000c01c38572$73c03c50$251a32d2@athlon2000> From: "Richard Sydney-Smith" To: Subject: Mystery function error Date: Sun, 28 Sep 2003 11:39:19 +0800 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0007_01C385B5.274A2050" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - server146.hostingrevolution.com X-AntiAbuse: Original Domain - postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [0 0] / [47 12] X-AntiAbuse: Sender Address Domain - ibisaustralia.com X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.7 tagged_above=0.0 required=5.0 tests=BAYES_30, HTML_40_50, RCVD_IN_OSIRUSOFT_COM X-Spam-Level: X-Archive-Number: 200309/355 X-Sequence-Number: 15333 This is a multi-part message in MIME format. ------=_NextPart_000_0007_01C385B5.274A2050 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable As I am converting from Sybase I wanted to create a function which would re= plicate the behaviour of the sybase "Locate" command. The goal is to have=20 locate( stra, strb) =3D position(strb in stra) where "position" is the standard postgres function for the index position o= f string "A" in string "B" My attempt at a function to do this task returns the error message=20 ERROR: parse error at or near '"'=20=20=20=20 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=20 srcstr alias for $1; searchstr alias for $2; begin return position(searchstr in srcstr); ' LANGUAGE 'plpgsql' VOLATILE; ---------------------------------------------------------------------------= ---------------------------------- Thanks very much=20 Richard ------=_NextPart_000_0007_01C385B5.274A2050 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
As I am converting from Sybase I wanted to= create a=20 function which would replicate the behaviour of the sybase "Locate"=20 command.
 
The goal is to have
 
locate( stra, strb) =3D position(strb in= =20 stra)
 
where "position" is the standard postgres = function=20 for the index position of string "A" in string "B"
 
My attempt at a function to do this task r= eturns=20 the error message
 
ERROR: parse error at or near '"' &nb= sp; =20
 
I can not see why.... and have attached th= e simple=20 function.
 
------------------------------------------------------------------= ------------------------------------
CREATE OR REPLACE FUNCTION public.locate(b= pchar,=20 bpchar)
  RETURNS int4 AS
'
  -- search for the position of $2 in= =20 $1
 
  declare
    srcs= tr alias=20 for $1;
    searchstr alias for $2;
 
begin
return position(searchstr in=20 srcstr);
'
  LANGUAGE 'plpgsql' VOLATILE;
------------------------------------------------------------------= -------------------------------------------
 
Thanks very much
 
Richard
------=_NextPart_000_0007_01C385B5.274A2050--