View previous topic :: View next topic |
Author |
Message |
satishsv Beginner
Joined: 29 Mar 2004 Posts: 6 Topics: 3 Location: Pella, IA
|
Posted: Mon Mar 29, 2004 11:28 pm Post subject: Regarding Substring in DB2 |
|
|
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 |
|
 |
satishsv Beginner
Joined: 29 Mar 2004 Posts: 6 Topics: 3 Location: Pella, IA
|
Posted: Tue Mar 30, 2004 12:53 am Post subject: |
|
|
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 |
|
 |
satishsv Beginner
Joined: 29 Mar 2004 Posts: 6 Topics: 3 Location: Pella, IA
|
Posted: Tue Mar 30, 2004 1:27 am Post subject: |
|
|
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 |
|
 |
vini Intermediate
Joined: 12 Jan 2004 Posts: 240 Topics: 48 Location: Maryland
|
Posted: Tue Mar 30, 2004 10:36 am Post subject: |
|
|
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 |
|
 |
vini Intermediate
Joined: 12 Jan 2004 Posts: 240 Topics: 48 Location: Maryland
|
Posted: Tue Mar 30, 2004 12:08 pm Post subject: |
|
|
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 |
|
 |
|
|