IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

how retrieve first 5 character in db2


IBM Mainframe Forums -> Mainframe Interview Questions
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
raman.k

New User


Joined: 26 Feb 2007
Posts: 24
Location: chennai

PostPosted: Mon Mar 26, 2007 7:17 pm
Reply with quote

hi
I have one question in DB2. I have table name is EMP. it have emp_name field. now i want display emp_name in first 5 character only
how is it position please tell me
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Mon Mar 26, 2007 10:13 pm
Reply with quote

Hello,

You could define a new working-storage variable called ws-emp_name and give it a picture of x(5).
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Mon Mar 26, 2007 10:40 pm
Reply with quote

Isn't there a "substring" command?
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Mon Mar 26, 2007 11:17 pm
Reply with quote

Yup, but i don't think it can be used in SQL . . .

Becomes a matter of defining the "short" field or using the substring/reference modification each time the "sort" valueis needed.
Back to top
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1042
Location: Richmond, Virginia

PostPosted: Tue Mar 27, 2007 12:01 am
Reply with quote

DB2:

SUBSTR(string-expression,start[,length])

where [...] is optional
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> Mainframe Interview Questions

 


Similar Topics
Topic Forum Replies
No new posts Help with C character vs C string All Other Mainframe Topics 3
No new posts Using Java/C/C++ to retrieve dataset ... Java & MQSeries 6
No new posts Panvalet - 9 Character name - Issue c... CA Products 6
No new posts String has hex character need to conv... COBOL Programming 3
No new posts Output LREC based on specific character DFSORT/ICETOOL 22
Search our Forums:

Back to Top