473,406 Members | 2,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Data type convert issue

See the following example.

db2 =create table aaa (c1 decimal(10,3));
DB20000I The SQL command completed successfully.

db2 =insert into aaa values (200.03);
DB20000I The SQL command completed successfully.
db2 =select * from aaa;

C1
------------
200.030

1 record(s) selected.

db2 =select char(c1) from aaa;

1
------------
0000200.030

1 record(s) selected.

The result is not what I want. I want to the result to be 200.03 as
CHAR type. How can I do this convert?

Thanks in advance.

James

Jun 2 '07 #1
3 4266
James wrote:
db2 =select char(c1) from aaa;

1
------------
0000200.030

The result is not what I want. I want to the result to be 200.03 as CHAR type. How can I do this convert?
Maybe there are the better ways, but, if nothing else, you can write UDF in C language, and make any sofisticated 'printf' formatting...
--
Konstantin Andreev.
Jun 2 '07 #2
James wrote:
See the following example.

db2 =create table aaa (c1 decimal(10,3));
DB20000I The SQL command completed successfully.

db2 =insert into aaa values (200.03);
DB20000I The SQL command completed successfully.
db2 =select * from aaa;

C1
------------
200.030

1 record(s) selected.

db2 =select char(c1) from aaa;

1
------------
0000200.030

1 record(s) selected.

The result is not what I want. I want to the result to be 200.03 as
CHAR type. How can I do this convert?
Check if STRIP is available on your system.
Also check TRIM which is very similar on new DB2's
http://publib.boulder.ibm.com/infoce...c/r0023197.htm

Cheers
Serge

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Jun 2 '07 #3
On Jun 2, 8:11 pm, Serge Rielau <srie...@ca.ibm.comwrote:
James wrote:
See the following example.
db2 =create table aaa (c1 decimal(10,3));
DB20000I The SQL command completed successfully.
db2 =insert into aaa values (200.03);
DB20000I The SQL command completed successfully.
db2 =select * from aaa;
C1
------------
200.030
1 record(s) selected.
db2 =select char(c1) from aaa;
1
------------
0000200.030
1 record(s) selected.
The result is not what I want. I want to the result to be 200.03 as
CHAR type. How can I do this convert?

Check if STRIP is available on your system.
Also check TRIM which is very similar on new DB2'shttp://publib.boulder.ibm.com/infocenter/db2luw/v9/topic/com.ibm.db2....

Cheers
Serge

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab- Hide quoted text -

- Show quoted text -
It may be depend on client program whether leading and trailing ZEROs
are displayed.

But, wheather client program returns what format, if you are using DB2
9, you can use strip function to get the format you want.
Like this:
STRIP(CHAR(200.03), B, '0')
Otherwise, you can use LTRIM and RTRIM instead of STRIP functin.
TRANSLATE(RTRIM(LTRIM(TRANSLATE(CHAR(200.03), ' ', '0'))),'0',' ')

Jun 2 '07 #4

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

Similar topics

21
by: Batista, Facundo | last post by:
Here I send it. Suggestions and all kinds of recomendations are more than welcomed. If it all goes ok, it'll be a PEP when I finish writing/modifying the code. Thank you. .. Facundo
8
by: Du | last post by:
I'm trying to automate the upload process to yousendit.com, but the file size doesn't add up and yousendit.com keep rejecting my upload (it accepts the upload until the very end) I don't know...
1
by: Asaf Ganot | last post by:
Hi, I'm looking for a way to retrieve the date type of a registry value using c#. Since I couldn't find a way to do it with 'Microsoft.Win32', I tried to use the good old API call 'RegEnumValue'...
6
by: Rod Snyder | last post by:
I'm trying to set up an asp.net (vb.net) that will allow a user to insert/update a bio/profile. I wanted to create a SQL Server 2000 table that includes their contact info and bio info. However,...
2
by: Robert Smith jr. | last post by:
Hello, Please pardon my newbie question ... I am building an ASP.NET page that displays a recordset with a Delete statement enabled (this all works fine). I want to Insert the current row...
2
by: x | last post by:
hi i am a pilot by profession. i want to create a database of my logbook using ms access 2002. i am facing a problem regarding the format of time field. when i select "Data/Time" data type for my...
5
by: dananrg | last post by:
I was messing around with the native ODBC module (I am using Python in a Win32 environment), e.g: import dbi, odbc ....and it seems to meet my needs. I'd rather use a module that comes...
1
by: neeraj | last post by:
Hi All Can any give me the code for convert "DataColumn" data type of "DataTable". Even if data table already populated (have data) Actually I am creating one search module which searches the...
3
by: =?Utf-8?B?SlA=?= | last post by:
Explanation: We have several SP that need to retrieve a single "Default Photo" from one of several Photo tables. The column in question in these tables is defined as an IMAGE data type. I...
0
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
0
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...
0
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
agi2029
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,...
0
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...

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.