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 

Packed item stored in CHAR type column

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


Joined: 05 Oct 2005
Posts: 31
Topics: 7

PostPosted: Fri Mar 03, 2006 3:05 am    Post subject: Packed item stored in CHAR type column Reply with quote

Dear Friends,
I have a column (say COL1) declared as CHAR 10 in DB2 table (say TAB1).
In this column, 1st position contains character value
and 2-4th positions contain packed numeric value
and the rest contains character value.
Now I want to see only the number stored in COL1.
I have used a following query in QMF
SELECT SUBSTR(COL1,2,2) FROM TAB1.
But this does not show me the number Embarassed . It only shows the compressed symbols. Is there any way that I can see the numeric value stored in this column?
Thanks for your responses.
Back to top
View user's profile Send private message
CZerfas
Intermediate


Joined: 31 Jan 2003
Posts: 211
Topics: 8

PostPosted: Fri Mar 03, 2006 4:36 am    Post subject: Reply with quote

I don't know from where you got this packed numeric value. If it is in fact a DB2 smallint, you can say
SELECT CAST(SUBSTR(COL1,2,2)) AS SMALLINT.

Alternatively you can at least have a look at the hexadecimal expression of this numeric value with
SELECT HEX(SUBSTR(COL1,2,2))

good luck
Christian
Back to top
View user's profile Send private message
astro
Beginner


Joined: 05 Oct 2005
Posts: 31
Topics: 7

PostPosted: Fri Mar 03, 2006 5:33 am    Post subject: Reply with quote

Dear Christian,
The Packed numeric item is passed to this column from application programs.
Well. Thanks for your speedy reply.
SELECT HEX(SUBSTR(COL1,2,2)) helped me to see the value in this case.
But CAST(SUBSTR(COL1,2,2)) AS SMALLINT does not work & I got SQLError for this stmt.
Once Again Thanks for your reply
Back to top
View user's profile Send private message
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