473,473 Members | 2,166 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Comparing a varchar of length > 32

Hello,

we are using a table with a primary key of type varchar[50].
If we try to find entries with select * from <table> where <table.key> =
'<text>';
entries with a key length of more than 32 characters are not found.
Entries with a shorter key are found. Using "Like" instead of "=" works for
varchar keys with length > 32 as well.

Does anybody know about this Problem ?
(We use PostgresQL 7.4.1)

Thanks in advance,
Christian Enklaar.


Nov 23 '05 #1
3 1754
Christian Enklaar wrote:
Hello,

we are using a table with a primary key of type varchar[50].
If we try to find entries with select * from <table> where <table.key> =
'<text>';
entries with a key length of more than 32 characters are not found.
Entries with a shorter key are found. Using "Like" instead of "=" works for
varchar keys with length > 32 as well.

Does anybody know about this Problem ?
(We use PostgresQL 7.4.1)


I think you are hiding some informations.

It works here with a 7.4.5 and I'm not aware of any bug like this in previous
versions.

test=# \d test
Table "public.test"
Column | Type | Modifiers
--------+-----------------------+-----------
a | character varying(50) | not null
Indexes:
"test_pkey" primary key, btree (a)
test=# select a, length(a) from test;
a | length
----------------------------------------------------+--------
01234567890123456789012345678901234567890123 | 44
0123456789012345678901234567890123456789 | 40
01234567890123456789012345678901234567890123456789 | 50
(3 rows)
test=# select length(a) from test where a = '01234567890123456789012345678901234567890123';
length
--------
44
(1 row)
Just an idea, could you reindex your table ?
Regards
Gaetano Mendola

Nov 23 '05 #2
Christian Enklaar wrote:
we are using a table with a primary key of type varchar[50].
If we try to find entries with select * from <table> where
<table.key> = '<text>';
entries with a key length of more than 32 characters are not found.
Entries with a shorter key are found. Using "Like" instead of "="
works for varchar keys with length > 32 as well.


Please post the actual table definitions, the actual data, the actual
command you are running, and the actual results you are getting.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/
---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org)

Nov 23 '05 #3
Hello,

thanks for your help.

Seems as if the problem was related to our locale settings.

We are running PostgreSQL on QNX and did not set any specific locale when
creating the database.

Now when we explicitely use LOCALE C on database creation everything works
fine.

"Christian Enklaar" <ch***************@mbs-software.de> schrieb im
Newsbeitrag news:ci***********@news.hub.org...
Hello,

we are using a table with a primary key of type varchar[50].
If we try to find entries with select * from <table> where <table.key> =
'<text>';
entries with a key length of more than 32 characters are not found.
Entries with a shorter key are found. Using "Like" instead of "=" works for varchar keys with length > 32 as well.

Does anybody know about this Problem ?
(We use PostgresQL 7.4.1)

Thanks in advance,
Christian Enklaar.

Nov 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: James | last post by:
I am currently working on a PHP based website that needs to be able to draw from Oracle, MS SQL Server, MySQL and given time and demand other RDBMS. I took a lot of time and care creating a...
7
by: Rick Caborn | last post by:
Does anyone know of a way to execute sql code from a dynamically built text field? Before beginning, let me state that I know this db architecture is built solely for frustration and I hope to...
5
by: dmhendricks | last post by:
Greetings, I have a question. I work on some SQL2k/ASP.NET apps at work. My predacessor, who created the databases/tables seemed to have liked to use 'char' for all text fields. Is there a...
10
by: Techie | last post by:
what's the difference of the two data types?
22
by: jdokos | last post by:
Hello, I have a question about VARCHAR fields. Our application groups here are starting to use VARCHARs much more frequently. Even VARCHAR (2) to (9) length fields. They say this is because...
7
by: James o'konnor | last post by:
hello. i have the next for create one table into db2 CREATE TABLE "MYSQUEMA"."TABLADEMO" ( "ID" INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY ( START WITH +0 INCREMENT BY +1 MINVALUE +0...
0
by: Christian Enklaar | last post by:
We are using a table with a primary key of type varchar. If we try to find entries with select * from <table> where <table.key> = '<text>'; entries with a key length of more than 32 characters are...
2
by: John | last post by:
Hi Everyone, I have a question about dynamically changing the length of a varchar(n) field, in case the value I'm trying to insert is too big and will give a "truncated" error, but before the...
0
by: maheshmohta | last post by:
Background Often while remodeling legacy application, one of the important tasks for the architects is to have an optimum usage of storage capabilities of database. Most of the legacy applications...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.