View previous topic :: View next topic
|
Author |
Message |
vidyaa
New User
Joined: 02 May 2008 Posts: 77 Location: chennai
|
|
|
|
Hi,
i need to check mutiple conditons using REXX based on the number of variables present
EX: A = 123,B=NH,C=' ',D='2008'
i need to retrieve the records where
A=123,B=NH & D='2008' Must leave out C as the value is blank
like IF (SUBSTR(RC.I,1,3)=A & SUBSTR(RC.I,4,2)=B & SUBSTR(RC.I,8,4)=D)
and this may go in loop so that the IF condition needs to differ based on the varibales having the values. we will not know which field is blank at what time it is also possible to have more than one filed blank.
please let me know your suggestions. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10886 Location: italy
|
|
|
|
Quote: |
please let me know your suggestions. |
very humble suggestion
try to express Your requirements in a more understandable way,
the issue may be clear to You, but the way You exposed does not make it clear for everybody... |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10886 Location: italy
|
|
|
|
trying to infer something from the info provided
recd is the thing You are trying to analyze
var1, var2, var3 are the variables You need to chek
here is a code snippe
Code: |
recd = "var1var2var3var4"
pos1 = 1; len1 = 4; var1 = "var1"
pos2 = 5; len2 = 4; var2 = ""
pos3 = 9; len3 = 4; var3 = ""
NOT_MATCHED = 0
MATCHED = 1
trace "I"
do 1
flag = NOT_MATCHED
if var1 <> "" & ,
substr(recd,pos1,len1) <> var1 then leave
if var2 <> "" & ,
substr(recd,pos2,len2) <> var2 then leave
if var3 <> "" & ,
substr(recd,pos3,len3) <> var3 then leave
flag = MATCHED
end
if flag = MATCHED then ,
say "MATCHED"
else ,
say "NOT MATCHED"
exit
|
|
|
Back to top |
|
|
vidyaa
New User
Joined: 02 May 2008 Posts: 77 Location: chennai
|
|
|
|
EX: say i have some variables
A=123
B=NE
C=' '
D=2008
my input file has
RECORD1:123,NE,D,2008
RECORD2:123,NE,T,2008
RECORD3:111,HN,U,2007
I Need to fetch all the records having the value A=123,B=NEand D=2008 we dont have condition for C as the value of C=" ' (blank)
the condition will be like
IF ((SUBSTR(RECORD.I,1,3)=A & SUBSTR(RECORD.I,5,2)=B&SUBSTR(RECORD.I,10,4)=D)) This will retrieve me
RECORD1:123,NE,D,2008
RECORD2:123,NE,T,2008
like wise my IF CONDITION needs to be altered as per the fields having values. if A is balnk in then i should leave that fileds and frame the condition with the fields B,C and D.
how can this be done is my question. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10886 Location: italy
|
|
|
|
then the code snippet given does just that, tested
this new snippet tests for not existing variables or empty variables
Code: |
recd = "var1var2var3var4"
pos1 = 1; len1 = 4; var1 = "var1"
pos2 = 5; len2 = 4; var2 = ""
drop var2
pos3 = 9; len3 = 4; var3 = ""
NOT_MATCHED = 0
MATCHED = 1
trace "I"
do 1
flag = NOT_MATCHED
if symbol('var1') = "VAR" & ,
strip(var1) <> "" & ,
substr(recd,pos1,len1) <> var1 then leave
if symbol('var2') = "VAR" & ,
strip(var2) <> "" & ,
substr(recd,pos2,len2) <> var2 then leave
if symbol('var3') = "VAR" & ,
strip(var3) <> "" & ,
substr(recd,pos3,len3) <> var3 then leave
flag = MATCHED
end
if flag = MATCHED then ,
say "MATCHED"
else ,
say "NOT MATCHED"
exit
|
|
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10886 Location: italy
|
|
|
|
this snippet is a bit more sophisticated
it builds the variable names dynamically from a list
Code: |
recd = "var1var2var3var4"
pos1 = 1; len1 = 4; var1 = "var1"
pos2 = 5; len2 = 4; var2 = ""
drop var2
pos3 = 9; len3 = 4; var3 = "var3"
NOT_MATCHED = 0
MATCHED = 1
vnam_l = "var1 var2 var3 var4"
vpos_l = "1 5 9 13"
vlen_l = "4 4 4 4"
trace "I"
flag = MATCHED
do v = 1 to words(vnam_l)
vnam = word(vnam_l,v)
vpos = word(vpos_l,v)
vlen = word(vlen_l,v)
vval = value(vnam)
if symbol(vnam) <> "VAR" then ,
iterate
if strip(vval) = "" then ,
iterate
if substr(recd,vpos,vlen) <> vval then do
flag = NOT_MATCHED
leave
end
end
if flag = MATCHED then ,
say "MATCHED"
else ,
say "NOT MATCHED"
exit
|
|
|
Back to top |
|
|
vidyaa
New User
Joined: 02 May 2008 Posts: 77 Location: chennai
|
|
|
|
Thank you for the suggestions ...
but this one displays me the records even if one varible is present but i dont want it that way
i need to check for the all the varibles having values if it is present in that record and then fetch only that record as i have specified in my example before.
your suggestion on this? |
|
Back to top |
|
|
vidyaa
New User
Joined: 02 May 2008 Posts: 77 Location: chennai
|
|
|
|
Thank you so much enrico-sorichetti
This is what i was seraching for its does it and can please tell me why you have used DROP VAR2 |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10886 Location: italy
|
|
|
|
Quote: |
i need to check mutiple conditons using REXX based on the number of variables present
EX: A = 123,B=NH,C=' ',D='2008'
i need to retrieve the records where
A=123,B=NH & D='2008' Must leave out C as the value is blank
|
my samples just do that
if any of the source variables are not defined,or blanks or empty,
the comparison is skipped
written, made better, tested, found working as per quoted requirement, and posted
Quote: |
your suggestion on this? |
just learn to express Your requirements in a non misleading way, please
added multiple records, tested as per original requirement
Code: |
recd.0 = 5
recd.1 = "var1var2var3var4"
recd.2 = "var1varxvar3var4"
recd.3 = "var1var2varxvar4"
recd.4 = "var1var2var3varx"
recd.5 = "var1var2var3varx"
var1 = "var1"
var3 = "var3"
NOT_MATCHED = 0
MATCHED = 1
vnam_l = "var1 var2 var3 var4"
vpos_l = "1 5 9 13"
vlen_l = "4 4 4 4"
do r = 1 to recd.0
recd = recd.r
trace "O"
flag = MATCHED
do v = 1 to words(vnam_l)
vnam = word(vnam_l,v)
vpos = word(vpos_l,v)
vlen = word(vlen_l,v)
vval = value(vnam)
if symbol(vnam) <> "VAR" then ,
iterate
if strip(vval) = "" then ,
iterate
if substr(recd,vpos,vlen) <> vval then do
flag = NOT_MATCHED
leave
end
end
if flag = MATCHED then ,
say "MATCHED " r recd.r
else ,
say "NOT MATCHED" r recd.r
end
exit
|
|
|
Back to top |
|
|
vidyaa
New User
Joined: 02 May 2008 Posts: 77 Location: chennai
|
|
|
|
Thank you so much for the help provided on this enrico-sorichetti |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10886 Location: italy
|
|
|
|
the drop statement was to test for no existance of a variable...
there is a glitch in the last snippet
Code: |
... before
vlen = word(vlen_l,v)
vval = value(vnam)
if symbol(vnam) <> "VAR" then ,
iterate
if strip(vval) = "" then ,
iterate
|
Code: |
... after
vlen = word(vlen_l,v)
if symbol(vnam) <> "VAR" then ,
iterate
vval = value(vnam)
if strip(vval) = "" then ,
iterate
|
it is wiser to retrieve a variable value after having checked its existence |
|
Back to top |
|
|
vidyaa
New User
Joined: 02 May 2008 Posts: 77 Location: chennai
|
|
|
|
Got it thank you |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hi Enrico,
Quote: |
there is a glitch in the last snippet |
Long ago someone told me that bugs were "sons of glitches". . . . |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10886 Location: italy
|
|
|
|
Hi Dick,
I hope You will forgive my glitch
the snippet was written an tested while answering the TS
( ... can be seen by the messages timestamps )
I promise to be more careful in the future |
|
Back to top |
|
|
vidyaa
New User
Joined: 02 May 2008 Posts: 77 Location: chennai
|
|
|
|
hi enrico,
this one executed fast for few records but my input has billons od records its very slow on doing this is there any way to make it better and faster.
Suggestions on this will be of great help |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
billiions of records is considered needed info when talking about rexx. rexx is not a high end i/o utility. you could compile your rexx.
you could build sort control statements
or
write a cobol/pl1/assembler module to process this data. |
|
Back to top |
|
|
vidyaa
New User
Joined: 02 May 2008 Posts: 77 Location: chennai
|
|
|
|
this rexx consists of panels and rexx codes, where the user input some values i need tovalidate each fields and throw message after validation take the values entered by the user and search if the combination of values entered by the user is present in a file which is going to have billion of records if the combination exists writes it to a file if not pops up an error message as 'Combination not found' and all these will be done online REXX validtions will be the backend so its not possible to put this in a batch mode.Searching of the combinations of field values entered by the user in the file containing billion of records takes me time. |
|
Back to top |
|
|
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
Hi,
I can't believe anyone could come up with such a design, how often are these requests run ? how many users can request this ? what is the current time it takes to satisfy one of these requests ?
Surely the values entered by the user can be validated and saved into a file which can then be used in batch.
I would try to capture all requests into one file and run a batch job on a daily basis.
Gerry |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8796 Location: Welsh Wales
|
|
|
|
Gerry, stop it will you, coming up with sensible suggestions
What do you think this is, a help forum or something |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
If the concept has been proven, it would be best to do as DBZ suggests and re-code the process in a better suited language.
REXX may be the worst choice for processing high volumes of data. . . |
|
Back to top |
|
|
Pedro
Global Moderator
Joined: 01 Sep 2006 Posts: 2593 Location: Silicon Valley
|
|
|
|
Quote: |
search if the combination of values entered by the user is present in a file which is going to have billion of records if the combination exists |
If this is searched regularly, I think the data is stored in the wrong format. There is not really a good way to search billions of records stored in a sequential format. It should be in a database, where it might take the reading of a few index blocks before finding (or not) the record. |
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
Billions of records, Millions of records I think some of these record estimates are a little off. |
|
Back to top |
|
|
Pedro
Global Moderator
Joined: 01 Sep 2006 Posts: 2593 Location: Silicon Valley
|
|
|
|
Quote: |
my input has billons od records its very slow on doing this is there any way to make it better and faster. |
It is hard to believe that you got to billions of records without first realizing that there were performance problems. When you say 'billions', I am just assuming that you really meant "large number of records".
The way to speed it up is to not use a sequential file. Use VSAM with keyed records. I think you can get tools to process VSAM from rexx. (or as I said earlier, use a real database). |
|
Back to top |
|
|
vidyaa
New User
Joined: 02 May 2008 Posts: 77 Location: chennai
|
|
|
|
yes i got your words intially it was thought to be few record and now it has come to billions. This is need to process online to get the user input and validate and throw him error messages. this cannot be changed to a program i guess. the seraching part kills time is there any way to incorporate this searching part in languale like cobol and combine with rexx as this needs to be done online. |
|
Back to top |
|
|
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
Hi,
I want to be the user entering the data and waiting for the results.
I'll have to find ways of amusing myself.
Gerry |
|
Back to top |
|
|
|