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 

Regarding Substring in DB2

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


Joined: 29 Mar 2004
Posts: 6
Topics: 3
Location: Pella, IA

PostPosted: Mon Mar 29, 2004 11:28 pm    Post subject: Regarding Substring in DB2 Reply with quote

Hi,

I have a field called FIRST_NM in a table. It is declared as CHAR(30).

The field can contain a value as 'JOHN B'

My requirement is to get the character 'B' into a working-storage variable.

Is this possible? If so, how?

Thanking you in advance.

Satish
Back to top
View user's profile Send private message
satishsv
Beginner


Joined: 29 Mar 2004
Posts: 6
Topics: 3
Location: Pella, IA

PostPosted: Tue Mar 30, 2004 12:53 am    Post subject: Reply with quote

Thank you very much for the timely help, Ravi.

Infact, I was breaking my head to get this one as the requirement restricts me from using host language.

Moreover, performance is not an issue over here.

I have a small doubt here i.e., will this query work if I have more than 5 or 10 spaces after the first name.

Thanks & Regards,
Satish
Back to top
View user's profile Send private message
satishsv
Beginner


Joined: 29 Mar 2004
Posts: 6
Topics: 3
Location: Pella, IA

PostPosted: Tue Mar 30, 2004 1:27 am    Post subject: Reply with quote

Thank you very much Ravi. I have checked up the query in the way you have given in QMF and it gives the same result as I was expecting.

Thanks & Regards,
Satish
Back to top
View user's profile Send private message
vini
Intermediate


Joined: 12 Jan 2004
Posts: 240
Topics: 48
Location: Maryland

PostPosted: Tue Mar 30, 2004 10:36 am    Post subject: Reply with quote

Ravi said:
Quote:
But as far as I think do the substring part in host language. Using two functions in a select query will reduce the performance.


Functions degrade performance only when used as part of the 'Where Predicates' of a Query , not when merely used as part of the Column Select.

Vini
Back to top
View user's profile Send private message
vini
Intermediate


Joined: 12 Jan 2004
Posts: 240
Topics: 48
Location: Maryland

PostPosted: Tue Mar 30, 2004 12:08 pm    Post subject: Reply with quote

When computing Table columns its a fast and efficient way to use SQL Column Functions in the Select itself as opposed to doing the same thing via the Program logic. The only exception to this is when a corresponding function does not exist for what you need , in the SQL.
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