Обсуждение: BUG #3732: Select returns 0 rows for varchar field

Поиск
Список
Период
Сортировка

BUG #3732: Select returns 0 rows for varchar field

От
"George Woodman"
Дата:
The following bug has been logged online:

Bug reference:      3732
Logged by:          George Woodman
Email address:      georgew@computerspecialists.co.za
PostgreSQL version: 8.2.5
Operating system:   Windows 2000
Description:        Select returns 0 rows for varchar field
Details:

I created a table with the following specs.
CREATE TABLE user_control
(
  uci character varying(10) NOT NULL,
  ucname character varying(20),
  ucpwd character varying(10),
  ucrole character varying(20),
  CONSTRAINT user_control_pkey PRIMARY KEY (uci)
)
WITH (OIDS=FALSE);
ALTER TABLE user_control OWNER TO postgres;
GRANT ALL ON TABLE user_control TO postgres;

I have 2 records with the following details:
george,George,george,developer
1234567890,Temp,0,developer
When I try to retrieve this record with the following statement from a
ASP.Net (VB) app I get no rows returned.
Select * from user_control where uci = 'george'
However this statement works.
Select * from user_control where uci = '1234567890'

Re: BUG #3732: Select returns 0 rows for varchar field

От
Heikki Linnakangas
Дата:
George Woodman wrote:
> I created a table with the following specs.
> CREATE TABLE user_control
> (
>   uci character varying(10) NOT NULL,
>   ucname character varying(20),
>   ucpwd character varying(10),
>   ucrole character varying(20),
>   CONSTRAINT user_control_pkey PRIMARY KEY (uci)
> )
> WITH (OIDS=FALSE);
> ALTER TABLE user_control OWNER TO postgres;
> GRANT ALL ON TABLE user_control TO postgres;
>
> I have 2 records with the following details:
> george,George,george,developer
> 1234567890,Temp,0,developer
> When I try to retrieve this record with the following statement from a
> ASP.Net (VB) app I get no rows returned.
> Select * from user_control where uci = 'george'
> However this statement works.
> Select * from user_control where uci = '1234567890'

Works for me. Make sure there's no trailing spaces when you insert the data.

--
   Heikki Linnakangas
   EnterpriseDB   http://www.enterprisedb.com

Re: BUG #3732: Select returns 0 rows for varchar field

От
Alvaro Herrera
Дата:
George Woodman wrote:

> I have 2 records with the following details:
> george,George,george,developer
> 1234567890,Temp,0,developer
> When I try to retrieve this record with the following statement from a
> ASP.Net (VB) app I get no rows returned.
> Select * from user_control where uci = 'george'
> However this statement works.
> Select * from user_control where uci = '1234567890'

Are you sure 'george' does not have whitespace at the end?  My bet is
that it is actually 'george    '

--
Alvaro Herrera                 http://www.amazon.com/gp/registry/CTMLCN8V17R4
"Postgres is bloatware by design: it was built to house
 PhD theses." (Joey Hellerstein, SIGMOD annual conference 2002)