Connecting Tech Pros Worldwide Help | Site Map
 
 
LinkBack Thread Tools Search this Thread
  #1  
Old November 12th, 2005, 07:25 AM
alederer
Guest
 
Posts: n/a
Default 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
  #2  
Old November 12th, 2005, 07:25 AM
alederer
Guest
 
Posts: n/a
Default Re: Function to convert for bit data column to string?

alederer schrieb:
[color=blue]
> 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?
>[/color]

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

  #3  
Old November 12th, 2005, 07:25 AM
Serge Rielau
Guest
 
Posts: n/a
Default Re: Function to convert for bit data column to string?

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
  #4  
Old November 12th, 2005, 07:25 AM
Knut Stolze
Guest
 
Posts: n/a
Default Re: Function to convert for bit data column to string?

alederer wrote:
[color=blue]
> My problem:
> Where can I find the information that a column is for bit data?
> I have nothing found in syscat.columns![/color]

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
  #5  
Old November 12th, 2005, 07:25 AM
Serge Rielau
Guest
 
Posts: n/a
Default Re: Function to convert for bit data column to string?

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
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 205,248 network members.