Inserting string in FOR BIT DATA column in DB2

10,091

For Bit Data prevents the code page convertion between the client and the server. This is normally used to insert binary data, instead of strings.

Please, take a look at this forum, where many cases are proposed and solved: http://www.dbforums.com/db2/1663992-bit-data.html

You could eventually make a cast to database page (it depends you platform)

CAST(c1 AS CHAR(n) FOR SBCS DATA)

CAST (<forbitdataexpression> AS [VARCHAR|CHAR][(<n>)] FOR [SBCS|DBCS] DATA)

References

Share:
10,091
user2310198
Author by

user2310198

Updated on June 04, 2022

Comments

  • user2310198
    user2310198 almost 2 years

    When i try inserting a string value in a column in DB2, which is defined as CHAR(15) FOR BIT DATA, i notice that it gets converted into some other format, probably hexadecimal.

    On retrieving the data, i get a byte array, and on trying to convert it back to ASCII, using System.Text.Encoding.ASCII.GetString, i get back a string of some junk characters.

    Anyone faced this issue? Any resolution?

    Thanks in advance.