Re: How do I...

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Paul Tomblin <ptomblin(at)xcski(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: How do I...
Date: 2001-04-02 02:22:05
Message-ID: 3243.986178125@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Paul Tomblin <ptomblin(at)xcski(dot)com> writes:
> How do I compare a char (bpchar?) to a varchar? I tried using "=", and I
> got:

> waypoint=> select b.id, a.icao,a.faa_host_id from dafif_arpt a, waypoint b
> where b.id = a.icao;
> ERROR: Unable to identify an operator '=' for types 'varchar' and 'bpchar'
> You will have to retype this query using an explicit cast

> Why isn't this working?

char and varchar are not directly comparable because they have different
ideas about whether trailing blanks are significant. Postgres makes you
cast one or the other so that it knows which set of comparison rules to
apply. Typically you probably want to cast the varchar side to char so
that trailing blanks are ignored.

> It doesn't work even if I try to cast the varchar to bpchar:

I believe you are also running into sundry bugs in 6.5's handling of
these casts. Should be cleaned up in 7.0.*.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2001-04-02 02:25:18 Re: pg_ctl stop returns error
Previous Message Murakami 2001-04-02 01:34:58 pg_ctl stop returns error