Re: Order of SUBSTR and UPPER in statement

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Hermann Muster <Hermann(dot)Muster(at)gmx(dot)de>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Order of SUBSTR and UPPER in statement
Date: 2008-02-13 18:57:19
Message-ID: 20080213185719.GA90832@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Feb 13, 2008 at 04:19:09PM +0100, Hermann Muster wrote:
> I encountered something I can't really explain. I use the following
> statement in my application:
>
> COALESCE(UPPER(SUBSTR("Y"."Firma",1,7)),'')
>
> This returns "ERROR: syntax error at end of input"

Please show a complete statement and not just a portion of it. This
expression works for me:

test=> CREATE TABLE "Y" ("Firma" varchar);
CREATE TABLE
test=> INSERT INTO "Y" ("Firma") VALUES ('abcdefghij');
INSERT 0 1
test=> SELECT COALESCE(UPPER(SUBSTR("Y"."Firma",1,7)),'') FROM "Y";
coalesce
----------
ABCDEFG
(1 row)

> However, using the following statement is fine:
>
> COALESCE(SUBSTR(UPPER("X"."Firma"), 1, 7), '')
>
>
> The fieldtype of "Firma" is character varying.
>
> The only difference is the order of UPPER and SUBSTR.

I doubt that; I suspect the query that's failing has some other
problem that's causing the syntax error. Take a closer look,
especially at the end of the query string ("syntax error at end of
input").

--
Michael Fuhr

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Koen Vermeer 2008-02-13 19:52:18 Re: Storing images as BYTEA or large objects
Previous Message Richard Huxton 2008-02-13 18:27:09 Re: SELECT CAST(123 AS char) -> 1