160 pts.
 AS/400 :search string in database
One file has 10 fields,all are in CHAR & Len 10. (arrival seqnence)

This file having 1 Million record and want to search perticular value in a record,say 'SAMUL400',also not aware in which field have to search.

Plz help me to build a logic for the above ...thanks

 

 



Software/Hardware used:
ASKED: December 18, 2009  10:16 AM
UPDATED: December 18, 2009  10:59 PM

Answer Wiki:
You could do something like this creat a data structure D DS D FIELD100 100 D FIELD1 10 D FIELD2 10 D FIELD3 10 D FIELD4 10 D FIELD5 10 D FIELD6 10 D FIELD7 10 D FIELD8 10 D FIELD9 10 D FIELD10 10 MOVE YOUR 10 FIELDS INTO THE DATA STRUCTURE THEN SCAN THE "FIELD100" FOR YOUR VALUE C EVAL FOUND = %SCAN('TESTVALUE' : FIELD100) IF "FOUND" HAS A VALUE, THAT IS THE STARTING POS OF WHERE IT'S FOUND YOU COULD THEN DIVIDE THE "FOUND" VALUE BY 10 AND USE IT TO FIND THE CORRECT FIELD CONTAINING THE VALUE
Last Wiki Answer Submitted:  December 18, 2009  8:10 pm  by  ToddN2000   3,890 pts.
All Answer Wiki Contributors:  ToddN2000   3,890 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

so in RPG if you wanted the record and the field you might do this
Select
When %SCAN(‘TESTVALUE’ : FIELD1) > 0

When %SCAN(‘TESTVALUE’ : FIELD2) > 0
etc.

but you could also to this in SQL
where Field1 like ‘%TESTVALUE%’ or Field2 like ‘%TESTVALUE%’ etc

or in Query with the equilivant…
Phil

 44,070 pts.