Re: View fields are cast as text and link to Access as a Memo field - Mailing list pgsql-general

From Tom Lane
Subject Re: View fields are cast as text and link to Access as a Memo field
Date
Msg-id 28912.1201653995@sss.pgh.pa.us
Whole thread Raw
In response to View fields are cast as text and link to Access as a Memo field  (Karen Springer <karen.springer@wulfsberg.com>)
List pgsql-general
Karen Springer <karen.springer@wulfsberg.com> writes:
> I need employeeName to be a text field in Access.  I have tried casting
> the fields in the view as varchar, but it seem to default back to ::text.

The result of a || operator is always going to be type text.  Put the
cast around the whole expression, not just the individual fields.
For instance,

        CASE
            WHEN "Participant_Names"."NameUsed" IS NULL THEN
("Participant_Names"."LastNAME" || ', ') || "Participant_Names"."FirstName"
            ELSE ("Participant_Names"."LastNAME" || ', ') || "Participant_Names"."NameUsed"
        END :: varchar AS "employeeName"

            regards, tom lane

pgsql-general by date:

Previous
From: Karen Springer
Date:
Subject: View fields are cast as text and link to Access as a Memo field
Next
From: "Selena Deckelmann"
Date:
Subject: Re: PGCon vs Postgresql Conference