From: | Dimitri Fontaine <dfontaine(at)hi-media(dot)com> |
---|---|
To: | Julius Tuskenis <julius(at)nsoft(dot)lt> |
Cc: | pgsql-admin(at)postgresql(dot)org |
Subject: | Re: operator does not exist |
Date: | 2010-03-19 09:16:01 |
Message-ID: | 87d3z0wu26.fsf@hi-media-techno.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-admin |
Julius Tuskenis <julius(at)nsoft(dot)lt> writes:
> select '1' = 1 results in true
This is a undecorated literal, which PostgreSQL will cast as integer
when it discovers that's what makes sense.
> while select sum(msg_price) from messages where msg_itemid = 0 results in
> error:
> ERROR: operator does not exist: character varying = integer
> LINE 1: select sum(msg_price) from messages where msg_itemid = 0
Here, msg_itemid is known to be a varchar, and 0 is a numeric literal,
which is in the range of an integer, so the type is resolved as an
integer. Now the = operator does not exist for varchar, integer.
> I will add the operator ant then we'll fix the queries, but is the first
> example ok? Should it not raise error ?
Not as written. Try to decorate the literal to force PostgreSQL into
considering it of the type you have in mind:
SELECT text '1' = 1;
Or even do a cast, this way:
SELECT '1'::text = 1;
Regards,
--
dim
From | Date | Subject | |
---|---|---|---|
Next Message | Julius Tuskenis | 2010-03-19 10:16:48 | Re: operator does not exist |
Previous Message | Julius Tuskenis | 2010-03-19 07:24:05 | operator does not exist |