View previous topic :: View next topic
|
Author |
Message |
aryanpa1
New User
Joined: 26 May 2007 Posts: 45 Location: Chennai
|
|
|
|
Hi ,
I need to fetch the rows from a DB2 table which contains special characters in a particular column of length 30. Can you please help...
Special characters means : Not Numeric and Not Alphabetic
It means Other than A to Z and 0 to 9
Ex: ? , % @ #.... |
|
Back to top |
|
|
sri_mf
Active User
Joined: 31 Aug 2006 Posts: 218 Location: India
|
|
|
|
i am not getting u correctly...select " column " from table with give the results...
Explain ur problem clearly.. |
|
Back to top |
|
|
aryanpa1
New User
Joined: 26 May 2007 Posts: 45 Location: Chennai
|
|
|
|
Example:
Table has following columns
1)Student_id
2)Student_Name
Data in Table
---------------------------------------
Student_id Student_Name
--------------------------------------
1 pavan kumar
2 Anand$kumar
3 satish*%gorti
4 yugandhar
----------------------------------------
I need to fetch only rows with special characters , that is , the result should have the rows with Student_id's '2' and '3' only. |
|
Back to top |
|
|
sri_mf
Active User
Joined: 31 Aug 2006 Posts: 218 Location: India
|
|
|
|
aryanpa1 wrote: |
Example:
Table has following columns
1)Student_id
2)Student_Name
Data in Table
---------------------------------------
Student_id Student_Name
--------------------------------------
1 pavan kumar
2 Anand$kumar
3 satish*%gorti
4 yugandhar
----------------------------------------
I need to fetch only rows with special characters , that is , the result should have the rows with Student_id's '2' and '3' only. |
What u mean to say is that there may be special characters in the second field at any place.I think this can not be handled with DB2 query.U have to write a cobol program to separate those. Can any one suggest if there is any way other than what i have suggested. |
|
Back to top |
|
|
ksk
Active User
Joined: 08 Jun 2006 Posts: 355 Location: New York
|
|
|
|
Hi,
I think you can use wild characters in SQL query.
e.g., Student_Name LIKE '%$%' or '%*%' or '%#%' etc.
Please correct me if I am worng |
|
Back to top |
|
|
sri_mf
Active User
Joined: 31 Aug 2006 Posts: 218 Location: India
|
|
|
|
ksk wrote: |
Hi,
I think you can use wild characters in SQL query.
e.g., Student_Name LIKE '%$%' or '%*%' or '%#%' etc.
Please correct me if I am worng |
Hi KSK,
We can use wild cards but we are not sure of the place of the occurances of the special characters. |
|
Back to top |
|
|
ksk
Active User
Joined: 08 Jun 2006 Posts: 355 Location: New York
|
|
|
|
Sri,
If we give '%*%', it selects all the rows which have * at any occurence e.g.
abc*123
dhfjdfjd*kdelwe
wjdhh*skjdhskdhsdhsdhs etc.
No need to know about the occurance of the special character. I think whatever you are saying would be done with Wild-Card '_' not with '%'.
KSK |
|
Back to top |
|
|
sri_mf
Active User
Joined: 31 Aug 2006 Posts: 218 Location: India
|
|
|
|
ksk wrote: |
Sri,
If we give '%*%', it selects all the rows which have * at any occurence e.g.
abc*123
dhfjdfjd*kdelwe
wjdhh*skjdhskdhsdhsdhs etc.
No need to know about the occurance of the special character. I think whatever you are saying would be done with Wild-Card '_' not with '%'.
KSK |
Then i think we have to write so many conditions (one each special char)using OR. |
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
Based on the column names I would guess that this is a class assignment. Are you suppose to solve this yourself without outside help? |
|
Back to top |
|
|
Alan Voss
New User
Joined: 29 Nov 2006 Posts: 32 Location: Jacksonville, FL
|
|
|
|
Perhaps you can write a UDF (User Defined Function) to scan the string for alphanumerics (and embedded spaces) |
|
Back to top |
|
|
|