473,774 Members | 2,270 Online
Bytes | Software Development & Data Engineering Community
+ 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 1773
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.tes t"
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
----------------------------------------------------+--------
012345678901234 567890123456789 01234567890123 | 44
012345678901234 567890123456789 0123456789 | 40
012345678901234 567890123456789 012345678901234 56789 | 50
(3 rows)
test=# select length(a) from test where a = '01234567890123 456789012345678 901234567890123 ';
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 YourEmailAddres sHere" to ma*******@postg resql.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.or g...
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
2938
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 flexible and solid wrapper and am deep into coding. The only problem is a noticed VARCHAR fields being drawn from SQL Server 2000 are being truncated to 255 characters. I searched around php.net and found the following : Note to Win32 Users: Due...
7
6218
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 make it better soon. Unfortunately, there is never a non-crucial time in which we can do an upgrade, so we are stuck for now. Point 1: There are multiple tables: students, courses, cross-reference
5
29499
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 reason why he would have done this over using varchar? It's a minor annoyance to always have to RTRIM data and it makes directly making changes to the database more annoying (with all the pointless trailing spaces)? I usually use char for fixed...
10
71106
by: Techie | last post by:
what's the difference of the two data types?
22
11600
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 some of the application programs, specifically Java Beans cannot handle the spaces after the value in CHAR fields. Is anyone else seeing this trend?
7
4785
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 MAXVALUE +2147483647 NO CYCLE
0
1085
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 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)
2
6997
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 error is given! i.e. Is there some kind of a way to "test" the length of the field while Inserting the value into it, and to have it automatically increase its length to the length of the value being inserted, in case the value is too big? I've...
0
27259
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 are constrained by the technology available at the time of their development and hence aren’t optimum as per current scenario. One of such cases is the extensive usage of CHAR fields, which aren’t optimum solution for space storage now. This paper...
0
9454
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10267
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10040
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9914
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7463
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5484
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3611
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2852
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.