If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Reading raw datatype in native sql

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-17-10, 01:36
xs2shishir xs2shishir is offline
Registered User
 
Join Date: Sep 2010
Posts: 6
Reading raw datatype in native sql

I am trying to read data by joining tables from based on raw datatype column in sql query.

For eg: Select Col1, Col2 from table1 a, table2 b where a.col3 = b.col4
output of query = 0 Rows

Col3 and col4 defined as raw datatype in database. Please let me know how to resolve this issue. Any help is appreciated
Reply With Quote
  #2 (permalink)  
Old 09-17-10, 08:04
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
What do you mean by "raw datatype"? What DB2 version and OS are you using?

Andy
Reply With Quote
  #3 (permalink)  
Old 09-20-10, 02:45
xs2shishir xs2shishir is offline
Registered User
 
Join Date: Sep 2010
Posts: 6
I am not very sure but it is SAP backend. we are trying to download some data from backend based on query. OS is UNIX.
Reply With Quote
  #4 (permalink)  
Old 09-20-10, 08:07
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
What do you mean by "raw datatype"?

Andy
Reply With Quote
  #5 (permalink)  
Old 09-21-10, 02:34
xs2shishir xs2shishir is offline
Registered User
 
Join Date: Sep 2010
Posts: 6
I checked form SAP front end the datatype of the column. It says raw as a datatype of the physical field.
Reply With Quote
  #6 (permalink)  
Old 09-21-10, 08:31
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
Can you look in the database for the data type? DB2 has no data type that is "raw".

Andy
Reply With Quote
  #7 (permalink)  
Old 09-24-10, 03:15
xs2shishir xs2shishir is offline
Registered User
 
Join Date: Sep 2010
Posts: 6
I check at the backend table and found datatype mentioned for the column is CHARACTER with length of 16. But Actualy it stroes values of 32 bytes.
Reply With Quote
  #8 (permalink)  
Old 09-27-10, 08:23
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
Obviously you are not looking in the right place. You cannot store 32 bytes is a CHAR(16) field.

Andy
Reply With Quote
  #9 (permalink)  
Old 09-27-10, 14:41
xs2shishir xs2shishir is offline
Registered User
 
Join Date: Sep 2010
Posts: 6
I check in backend and it shows datatype as CHARACTER with length16. I am not able to see the data on the backend, but when I see data in SAP front end, I could see 32 some values like below

02018B4C780A9B18E1000000A3EC0393
02188B4C62159B18E1000000A3EC0393
023B8B4C8C109B18E1000000A3EC0393
Reply With Quote
  #10 (permalink)  
Old 09-27-10, 14:47
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
Either you are looking at the wrong thing, or SAP is adding something to the column when you get to see it.

Andy
Reply With Quote
  #11 (permalink)  
Old 09-27-10, 15:42
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
Run the following SQL, substituting the actual table and column names for both columns in question:
Code:
select tabschema, tabname, colname, typename, length, scale, codepage
from syscat.columns
where tabschema='YOURSCHEMA' and tabname='YOURTABLE' and colname='YOURCOLUMN'
Reply With Quote
  #12 (permalink)  
Old 09-27-10, 20:44
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
You might also be able to run the following:

describe table schema.table-name show detail

"show detail" is optional
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #13 (permalink)  
Old 09-28-10, 01:46
xs2shishir xs2shishir is offline
Registered User
 
Join Date: Sep 2010
Posts: 6
Thanks for all the replies, but I got the solution as below

SELECT COL1, VARCHAR_FORMAT_BIT(CAST(Col2 as VARCHAR2(16) as bit format), 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX') FROM tabl1
Reply With Quote
  #14 (permalink)  
Old 09-28-10, 08:09
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
Quote:
Originally Posted by xs2shishir View Post
I got the solution as below

SELECT COL1, VARCHAR_FORMAT_BIT(CAST(Col2 as VARCHAR2(16) as bit format), 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX') FROM tabl1
Doesn't seem to be related to your original question, but you're the boss...
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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