MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

SELECT for viewing Bit data

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
manojagrawal
Beginner


Joined: 25 Feb 2003
Posts: 124
Topics: 29

PostPosted: Thu Apr 24, 2003 8:07 am    Post subject: SELECT for viewing Bit data Reply with quote

Hi,

I have a field which is of type CHAR(32)

This field contains data which in which each individual bit represents something. What i want to do is run a SQL query to see the individual bits. I am not able to find any function for this. Any idea's?

Regards,
Manoj.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Thu Apr 24, 2003 10:14 am    Post subject: Reply with quote

Manoj,
I guess you meant each individual character instead of bit. You can use SUBSTR function with a case to validate each byte.

Code:


SELECT (CASE SUBSTR(COLA,1,1)                   
        WHEN 'A' THEN  'FIRST ALPHABET'         
        ELSE 'UNKNOWN'         
       END),                                     
       (CASE SUBSTR(COLA,2,1)                   
        WHEN 'B' THEN  'SECOND ALPHABET'                     
        ELSE 'UNKNOWN'         
       END)
       .....
       (CASE SUBSTR(COLA,32,1)                   
        WHEN 'B' THEN  'SECOND ALPHABET'   
        ELSE 'UNKNOWN'                         
       END)
 FROM TABLENAME WHERE COND1 = 'BLAH'
 ;


The above code validates the 1st character of the COLA and if it is 'A' then it prints as 'FIRST ALPHABET' else it will print 'UNKNOWN'

This is the same for all the 32 characters.

Hope this helps...

cheers

kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
manojagrawal
Beginner


Joined: 25 Feb 2003
Posts: 124
Topics: 29

PostPosted: Thu Apr 24, 2003 11:26 pm    Post subject: Reply with quote

Hi Kolusu,

What I meant was each BIT. Thus the 32 char field would have 32*8=256 bits.

I would like to see the individual bits using a SELECT. Is this possible???

Regards,
Manoj.
Back to top
View user's profile Send private message
Premkumar
Moderator


Joined: 28 Nov 2002
Posts: 77
Topics: 7
Location: Chennai, India

PostPosted: Fri Apr 25, 2003 2:23 am    Post subject: Reply with quote

If not available with SQL, you can use LE callable Bit Manipulation Routines.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group