Problem with LEFT function...

From: "Patrick Fiche" <patrick(dot)fiche(at)aqsacom(dot)com>
To: "PostgreSQL - General (E-mail)" <pgsql-general(at)postgresql(dot)org>
Subject: Problem with LEFT function...
Date: 2002-09-05 15:26:01
Message-ID: 85058ADF852DD5118FD50002A528A5B6079A33@SERVEUR
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I wonder if I'm not facing to a bug in PostgreSQL.

I defined for convenience a LEFT function like this :

----------------------------------------------------------------------------
----------------------------
CREATE OR REPLACE FUNCTION LEFT( text, int) RETURNS text AS '

DECLARE
_STRori ALIAS FOR $1;
_INTlength ALIAS FOR $2;

BEGIN

RETURN SUBSTRING( _STRori, 1, _INTlength );

END'
LANGUAGE 'plpgsql';
----------------------------------------------------------------------------
----------------------------

Then I want to use this function in SQL statements.

SELECT LEFT( 'String1', 3 ) -> Str

SELECT LEFT( 'String1', 3 ) || 'End' -> StrEnd

SELECT 'Begin' || SUBSTRING( 'String1', 1, 3 ) -> BeginStr

BUT

SELECT 'Begin' || LEFT( 'String1', 3 ) -> ERROR: parser: parse error at or
near "LEFT"

Perhaps I misunderstood something but it seems there is a problem in
PostgreSQL parser.

My version is : PostgreSQL 7.2.1 on i686-pc-linux-gnu, compiled by GCC 2.96.

Patrick Fiche
email : patrick(dot)fiche(at)aqsacom(dot)com
tél : 01 69 29 36 18

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Amin Abdulghani 2002-09-05 15:27:38 Transaction Id wraparounds
Previous Message Oleg Bartunov 2002-09-05 15:11:35 Re: Problem with restoring dump (may be tsearch-related)