473,327 Members | 2,016 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,327 software developers and data experts.

Function to convert for bit data column to string?

Hallo!

I need to convert the values of a varchar (..) for bit data column to a
string which can be stored in a normal varchar column (with additional
information).

Is there a function in db2 which supports this?
I think it must be possible to convert it in base64 format.
Of course I also need a function for the opposite direction.

Where can I find information how to do it?

Thanks
andreas
Nov 12 '05 #1
4 56022
alederer schrieb:
Hallo!

I need to convert the values of a varchar (..) for bit data column to a
string which can be stored in a normal varchar column (with additional
information).

Is there a function in db2 which supports this?
I think it must be possible to convert it in base64 format.
Of course I also need a function for the opposite direction.

Where can I find information how to do it?


ok, I have found one solution:
use HEX(column) to get the hex representation of the value.
Then I can use this representation with x'HEXVALUE' to insert it again
into a for bit data column.

My problem:
Where can I find the information that a column is for bit data?
I have nothing found in syscat.columns!

How can I retrieve this information?

thanks
andreas

Nov 12 '05 #2
In DB2 UDB V8 try:
CAST (<forbitdataexpression> AS [VARCHAR|CHAR][(<n>)] FOR [SBCS|DBCS] DATA)

Use SBCS in a single byte database, DBCS in a Unicode Database

Cheers
Serge
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #3
alederer wrote:
My problem:
Where can I find the information that a column is for bit data?
I have nothing found in syscat.columns!


It is in SYSCAT.COLUMNS, in the CODEPAGE column.

The codepage for a string column that is defined with the FOR BIT DATA
clause is 0, whereas it is the actual database code page for all other
string columns:

$ db2 "create table t ( a char(2) for bit data, b char(2) )"
$ db2 "select colname, codepage from syscat.columns where tabname = 'T'"

COLNAME CODEPAGE
----------------------------------- --------
A 0
B 819

2 record(s) selected.

--
Knut Stolze
Information Integration
IBM Germany / University of Jena
Nov 12 '05 #4
Minor revision:
In DB2 UDB V8 try:
CAST (<forbitdataexpression> AS [VARCHAR|CHAR][(<n>)] FOR [SBCS|MIXED] DATA)

Use SBCS in a single byte database, MIXED in a Unicode Database

Cheers
Serge
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #5

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

Similar topics

1
by: Swarup | last post by:
I am reading a file (txt, xml, gif, ico, bmp etc) byte by byte and filling it into a byte arry. Now i have to convert it into a string to store it in the database. I use...
30
by: ceeques | last post by:
Hi I am a novice in C. Could you guys help me solve this problem - I need to convert integer(and /short) to string without using sprintf (I dont have standard libray stdio.h). for...
3
by: bussiere maillist | last post by:
i've got a very long string and i wanted to convert it in binary like string = """Monty Python, or The Pythons, is the collective name of the creators of Monty Python's Flying Circus, a British...
10
by: sposes | last post by:
Im very much a newbie but perhaps somehone can help me. Ive been searching for a way to convert a std::string to a unsigned char* The situation is I have a function that wants a unsigned char*...
2
by: sypi | last post by:
Hi, I'd need to construnct an EXEC statement in my script I am pretty much stuck with data conversion. I need to compare a binary variable with a SID value to an actual SID found in ..sysusers. ...
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...
8
by: =?Utf-8?B?UmljYXJkbyBRdWludGFuaWxsYQ==?= | last post by:
i need to convert data from string to nibble wich (nibble is a four bits representation) As example i have the following code string data1 = "12345678"; so ¿how can i convert this data...
1
by: pnbaocuong | last post by:
Dear All When I try to use convert function of MS sql server like this: String sql = " (employee_id = '" + employee_id + "') and ((convert(VARCHAR,w_date,103) = '" + w_date + "'))"; ...
3
by: mamul | last post by:
Hi please some one can help me. how to convert char * to string? i have take char *argv from command line and want to pass to a function as string object(string str) i want to first convert argv...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.