maggielady
Technical User
I have a table that has an id # and a group description. The id # could be in there up to 148 times. I need to figure out a way to get, if the id# is in the table more than once with different group descriptions, into a field called church activites. Not sure how to get it to look at each record, and if the id# is found more than once, add that record to the church activities field. Here is my code to add church activities:
This puts things in one at a time, I need to put at least 148 possiblities in.
This is the way I started, with IF statements:
SELECT 25
SEEK(nperno)
DO while nperno=val(MBRID) .and. .not. eof()
IF nperno=VAL(MBRID)
CCHACTIV1=ALLTRIM(name) Skip
IF nperno=val(MBRID)
CCHACTIV2=ALLTRIM(name) Skip
And so on and on and on then I do this procedure to put in the the correct table:
PROCEDURE skchactiv
PARAMETERS cx1
if .not. isblank(cx1)
do lookfill with cx1,"CHACTIVITY",lastcode,lupkey
select 4
append blank
replace person_id with tperid
replace table_name with "CHACTIVITY"
replace table_id with lastcode
select 1
endif
Is there a better way the using IF or CASE statements 148 times??
This puts things in one at a time, I need to put at least 148 possiblities in.
This is the way I started, with IF statements:
SELECT 25
SEEK(nperno)
DO while nperno=val(MBRID) .and. .not. eof()
IF nperno=VAL(MBRID)
CCHACTIV1=ALLTRIM(name) Skip
IF nperno=val(MBRID)
CCHACTIV2=ALLTRIM(name) Skip
And so on and on and on then I do this procedure to put in the the correct table:
PROCEDURE skchactiv
PARAMETERS cx1
if .not. isblank(cx1)
do lookfill with cx1,"CHACTIVITY",lastcode,lupkey
select 4
append blank
replace person_id with tperid
replace table_name with "CHACTIVITY"
replace table_id with lastcode
select 1
endif
Is there a better way the using IF or CASE statements 148 times??