Here's the question:
How do you get DB2 to update a char(n) field with multiple spaces right
next to each other without having the additional spaces being omitted?
Here's the background:
We have a field "codes2" that's defined as char(8) that we use to keep
eight different codes (i.e. codes2[0] = something, codes2[1] =
something else, etc.). I'm sure that idea is nothing new to anyone but
our problem arises when we try to store two spaces (' ') right next to
each other.
This command:
EXEC SQL UPDATE TBLNAME SET CODES2 = '5H 7B3d' WHERE ...;
Completes without errors but when you look in the table to see what was
actually done, codes2 = '5H 7B3d', the DB2 just decided to omit one of
the spaces and slide the rest of the string over. You can imagine our
problem when we've got programs looking for the value in codes2[3] and
instead of finding a space (' ') it finds a 7...not good. 4 1674
I took a peek and did not find a problem. Could you try the following
code?
DECLARE GLOBAL TEMPORARY TABLE A (A CHAR(8))
INSERT INTO SESSION.A VALUES('5H 7B3d')
SELECT 1, '==>' || SUBSTR(A, 1, 1) || '<==' FROM SESSION.A UNION ALL \
SELECT 2, '==>' || SUBSTR(A, 2, 1) || '<==' FROM SESSION.A UNION ALL \
SELECT 3, '==>' || SUBSTR(A, 3, 1) || '<==' FROM SESSION.A UNION ALL \
SELECT 4, '==>' || SUBSTR(A, 4, 1) || '<==' FROM SESSION.A UNION ALL \
SELECT 5, '==>' || SUBSTR(A, 5, 1) || '<==' FROM SESSION.A UNION ALL \
SELECT 6, '==>' || SUBSTR(A, 6, 1) || '<==' FROM SESSION.A UNION ALL \
SELECT 7, '==>' || SUBSTR(A, 7, 1) || '<==' FROM SESSION.A UNION ALL \
SELECT 8, '==>' || SUBSTR(A, 8, 1) || '<==' FROM SESSION.A ORDER BY 1
UPDATE TBLNAME SET A = '5H 7B3d'
SELECT 1, '==>' || SUBSTR(A, 1, 1) || '<==' FROM SESSION.A UNION ALL \
SELECT 2, '==>' || SUBSTR(A, 2, 1) || '<==' FROM SESSION.A UNION ALL \
SELECT 3, '==>' || SUBSTR(A, 3, 1) || '<==' FROM SESSION.A UNION ALL \
SELECT 4, '==>' || SUBSTR(A, 4, 1) || '<==' FROM SESSION.A UNION ALL \
SELECT 5, '==>' || SUBSTR(A, 5, 1) || '<==' FROM SESSION.A UNION ALL \
SELECT 6, '==>' || SUBSTR(A, 6, 1) || '<==' FROM SESSION.A UNION ALL \
SELECT 7, '==>' || SUBSTR(A, 7, 1) || '<==' FROM SESSION.A UNION ALL \
SELECT 8, '==>' || SUBSTR(A, 8, 1) || '<==' FROM SESSION.A ORDER BY 1
DROP TABLE SESSION.A
B.
Hmm... Just playing with WITH.
DECLARE GLOBAL TEMPORARY TABLE A (A CHAR(8))
INSERT INTO SESSION.A VALUES('5H 7B3d')
WITH B (B) AS (VALUES 1, 2, 3, 4, 5, 6, 7, 8) SELECT B, (SELECT '==>'
|| SUBSTR(A, B, 1) || '<==' FROM SESSION.A) FROM B
UPDATE SESSION.A SET A = '5H 7B3d'
WITH B (B) AS (VALUES 1, 2, 3, 4, 5, 6, 7, 8) SELECT B, (SELECT '==>'
|| SUBSTR(A, B, 1) || '<==' FROM SESSION.A) FROM B
DROP TABLE SESSION.A
Mesan wrote: Here's the question: How do you get DB2 to update a char(n) field with multiple spaces right next to each other without having the additional spaces being omitted?
Here's the background: We have a field "codes2" that's defined as char(8) that we use to keep eight different codes (i.e. codes2[0] = something, codes2[1] = something else, etc.). I'm sure that idea is nothing new to anyone but our problem arises when we try to store two spaces (' ') right next to each other.
This command:
EXEC SQL UPDATE TBLNAME SET CODES2 = '5H 7B3d' WHERE ...;
Completes without errors but when you look in the table to see what was actually done, codes2 = '5H 7B3d', the DB2 just decided to omit one of the spaces and slide the rest of the string over. You can imagine our problem when we've got programs looking for the value in codes2[3] and instead of finding a space (' ') it finds a 7...not good.
What's the language the SQL is embedded into?
This does have a taste of a client bug.
Also which codepage is used. There are umpteen versions of space in
Unicode...
Cheers
Serge
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
The SQL is embedded into a C program running on OS/2 compiled with IBM
Visual Age C++ 3.0. If I remember right, the code page our OS/2
clients use to talk to our OS/2 server is 437, but I could be wrong
(although I'm almost positive). I could reproduce it through the
command line with manual insert commands. Very weird eh? I got the
problem fixed in the program by using a cursor (instead of a normal
"EXEC SQL ..." command) but still, it's a very odd problem.
Thanks for your reply,
Mesan This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Chris Sharman |
last post by:
Writing a form, several questions have got a list of checkboxes, with
associated descriptions (mostly one word), all on a line.
Eg:
Describe yourself: Fat Hairy Ugly Wears glasses.
I want to prevent the description word(s) from being separated from
their box (represented here as ""). I want to insert some spacing
between items, so that it's clear the third box means ugly, not hairy -
I've used " ", between items (as well as...
|
by: epaetz |
last post by:
I'm doing a bcp out of a table to a file. Some of the fields in a
record may have an empty string.
When I bcp out to the file and examine it, the fields that have an
empty string in the database now show up in the file as having one
blank character.
Why is bcp doing this? I don't want the blank character in my output.
Thanks,
|
by: gopal srinivasan |
last post by:
Hi,
I have a text like this -
"This is a message containing tabs and white spaces"
Now this text contains tabs and white spaces. I want remove the tabs
and white spaces(if it more than once between two words).
Is there any function we have in C which will find out the tabs and
white spaces and returns the text in the follwong way -
|
by: Magix |
last post by:
Hi,
Everytime I received a fix-length of string, let say 15 (the unused portion
will filled with Spaces before receive), I want to remove the Spaces from
END until I encounter a non-space char.
let say: testBuf is the buffer that receive this fix-length string.
printf("",testBuf);
Output:
|
by: barry |
last post by:
Have tried a number of things including space(n) in front of the string but
when the DropDownList is shown the spaces have apparently been trimmed.
Is this something that would have to be done in a custom control?
I would like the spaces to be at the front end of the string " xxxxx".
In vs.net I am doing a listitem(string)
Any Help is appreciated.
thanks
barry
| |
by: irsmartt |
last post by:
How can I allow a user (in a command prompt) to enter a string of
characters and put spaces in it? I use Dev C++. Example:
char google;
cin>> google;
Whenever I try this and output the variable, the string cuts off at the
end of a space. The odd thing is that the alt code space works, but not
|
by: DanielJohnson |
last post by:
I am writing a program in which I am removing all the spaces from the
string. I thought that I could do it two ways. One was parsing the
string character by character and copying onto another output string.
But this was trivial.
The other option is to use pointers and shift all the characters after
the space by one space to the left. I did this program using pointers
and then using array too and I get segmentation fault. What is going...
|
by: ramu |
last post by:
Hi,
Suppose I have a string like this:
"I have a string \"and a inner string\\\" I want to remove space in
this string but not in the inner string"
In the above string I have to remove spaces, but not in the inner
string(\"and a inner string\\\"). Will anyone please tell me how to do
this?
|
by: drjay1627 |
last post by:
hello,
This is my 1st post here!
*welcome drjay*
Thanks! I look answering questions and getting answers to other!
Now that we got that out of the way. I'm trying to read in a string and add the unique words in the string to a map. Eg:
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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...
| |
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,...
|
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| | |