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 

Identify characters/alphabet in DB2

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


Joined: 22 Jun 2005
Posts: 41
Topics: 14

PostPosted: Wed May 03, 2006 1:31 pm    Post subject: Identify characters/alphabet in DB2 Reply with quote

I have the following requirement

Code:


P1Code      Acode      PTYPCode
AB01      AB      AH
AB01      A1      AS            
AB01      A2      AK
AB01      ...      ...   
AB01      A5      AH
CD05      PP      CE
CD05      P1      CF         
CD05      ...      ...
CD05      P5      CD
KK09      CH      OE
KK09      C1      OE
KK09      ...      ...         
KK09      C5      OK




Now a new master row will be entered as


Code:

P1Code      Acode      PTYPCode
' '      HH      PU


- master row is one for which P1 Code is spaces.

Now I will have to replicate the master row to each of the P1Code with the other fields being the same from the master row, but only the Acode is differing as, rows are inserted as

Code:

P1Code      Acode      PTYPCode
AB01      AB      PU
CD05      PP      PU
KK09      CH      PU


In this case the total Acode value itself will change.

For example if the master row is

Code:

P1 Code      A code      PTYP Code
' '      H3      PU


Then the P1Code will have to be replicated as, rows are inserted as

Code:

P1Code      Acode      PTYPCode
AB01      A3      PU
CD05      P3      PU
KK09      C3      PU


In this case only the first letter of the ACode value will change, the second position which is a number will remain the same.

The question is, whether there is something in DB2 that allow me to check if the value of a particular field is alphabetic or a character. In this example the ACode has only 2 characters.

Just to make it more clear, I am looking for something in DB2 that will help me to identify whether the value of a particular field is a character. I might have to look for the position of the character also.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


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

PostPosted: Thu May 04, 2006 1:02 pm    Post subject: Reply with quote

geetha001,

you can check if a column has character data or not with following sql

Code:

WHERE SUBSTR(COL,2,1) IN ('A','B','C','D','E',   
                          'F','G','H','I','J',   
                          'K','L','M','N','O',   
                          'P','Q','R','S','T',   
                          'U','V','W','X','Y',   
                          'Z')


Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
geetha001
Beginner


Joined: 22 Jun 2005
Posts: 41
Topics: 14

PostPosted: Thu May 04, 2006 3:47 pm    Post subject: Reply with quote

Thanks Kolusu.
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