Return to the SQL Tips
Using SQL to do a Numeric search on Phone number.
Does your AS/400 have SQL? Test by executing the command STRSQL. If it does then use embedded SQL. Use the following sequence:
* ... D CustMastDS E DS extname(CMastR) prefix(DS) * ... C/EXEC SQL C+ Declare Cur1 Cursor for C+ Select * from CMastR where Cphone like :phone C/END-EXEC C/EXEC SQL C+ Open Cur1 C/END-EXEC C/EXEC SQL C+ Fetch Cur1 into :CustMastDS C/END-EXEC C DOW SQLCOD=0 C* process the entry. C* ... * Get next list entry. C/EXEC SQL C+ Fetch Cur1 into :CustMastDS C/END-EXEC C EndDo C/EXEC SQL C+ Close Cur1 C/END-EXEC C* ... If your phone number is numeric then you might have to change to: Select * from CMastR where digits(Cphone) like :phone To test using the STRSQL command use Select * from CMastR where digits(Cphone) like '708'
[report a broken link by clicking here]