anant desai
8th July 2012, 15:13
I have the the following piece of code:
main.table.io:
after.read:
select tdsls040.refa,tdsls045.ssls
from tdsls040,tdsls045
where tdsls040._index1={:tdsls045.orno}
and tdsls045.ssls=1
as set with 1 rows
selectdo
endselect
Main table is tdsls040.
Table tdsls045 has multiple records for the same orno.
Session is type1/2/3 display session with main table.
This displays ALL records of tdsls040, ignoring the
where clause tdsls045.ssls=1
mark_h
8th July 2012, 21:21
Sounds like the same problem that was posted once before. If I get it correctly you have one tdsls040 record to be displayed and multiple tdsls045 records. Plus you only want to display those tdsls040 records where it has a tdsls045 record where tdsls045.ssls=1. The program itself already has the current tdsls040 record - reading the table again would probably confuse the session.
main.table.io:
after.read:
select tdsls045.ssls
from tdsls045
where tdsls045._index1={:tdsls040.orno}
and tdsls045.ssls<>1
as set with 1 rows
selectdo
skip.io("")
endselect
PS - not familiar with these tables or relationships.
anant desai
9th July 2012, 13:59
The program works fine, thank you.
But the problem comes in when there
is no corresponding record in tdsls045.
I have coded the following:
selectempty
skip.io("").
Then no records are displayed.
mark_h
9th July 2012, 14:36
main.table.io:
after.read:
select tdsls045.ssls
from tdsls045
where tdsls045._index1={:tdsls040.orno}
and tdsls045.ssls<>1
as set with 1 rows
selectdo
skip.io("")
selectempty
| When it hits here it means there could be records with tdsls045.ssls=1
| now you need to verify it there are no records.
select tdsls045.ssls
from tdsls045
where tdsls045._index1={:tdsls040.orno}
as set with 1 rows
selectdo
selectempty
skip.io("")
endselect
endselect
Of maybe this which looks a little simpler to me.
main.table.io:
after.read:
|Skip if no tdsls045 records
select tdsls045.ssls
from tdsls045
where tdsls045._index1={:tdsls040.orno}
as set with 1 rows
selectdo
selectempty
skip.io("")
endselect
|skip if tdsls045.ssls not equal to 1
select tdsls045.ssls
from tdsls045
where tdsls045._index1={:tdsls040.orno}
and tdsls045.ssls<>1
as set with 1 rows
selectdo
skip.io("")
endselect