sukhija7
16th December 2016, 12:49
Hi,
Can anyone let me know the difference in following script..
Assuming vrinf502 as customized table
1.
select vrinf502.*
from vrinf502
where vrinf502.orno = :whinh225.orno
and vrinf502.ppon = :whinh225.pono
and vrinf502.ktwt = :whinh225.qadv
selectdo
flag.d2 = true
endselect
2. select vrinf502.*
from vrinf502
where vrinf502.orno = :whinh225.orno
and vrinf502.ppon = :whinh225.pono
selectdo
if vrinf502.ktwt = whinh225.qadv then
flag.d2 = true
endif
endselect
mark_h
19th December 2016, 14:49
(1) Finds all records for the 3 fields then loops thru continuously setting the flag to true. On this one I would as add "as set with 1 rows". No reason to do all that looping.
(2) This query finds all row for the 2 fields, then it checks all of them. If even one of them as a qadv field that matches the vrinf502.ktwt field then it sets the flag to true.
In essence the 2 queries do the same thing - set the flag to true if just one time vrinf502.ktwt = whinh225.qadv these match.
sukhija7
20th December 2016, 09:07
(1) Finds all records for the 3 fields then loops thru continuously setting the flag to true. On this one I would as add "as set with 1 rows". No reason to do all that looping.
(2) This query finds all row for the 2 fields, then it checks all of them. If even one of them as a qadv field that matches the vrinf502.ktwt field then it sets the flag to true.
In essence the 2 queries do the same thing - set the flag to true if just one time vrinf502.ktwt = whinh225.qadv these match.
Hi,
Concern is , first option is not working but 2nd option is working for a single set of record. why???
oirfeodent
20th December 2016, 10:21
Hi,
Concern is , first option is not working but 2nd option is working for a single set of record. why???
If you add order by clause to both the queries and re-init the flag in selectempty and initialize the flag before the start of query... you should be able to get a consistent result. Run-time scenarios/data-sets cannot be predicted.
mark_h
20th December 2016, 14:42
Hi,
Concern is , first option is not working but 2nd option is working for a single set of record. why???
I would be checking my code if the first option is not working. I would check all the domains for the table fields and make sure they line up. Not being familiar with the data I can't say for sure what exactly is the reason. But based off what you posted the first should work.
If that second field is a double or something like that then you could be running into a precision issue. We once had code that said if x=y do this - it worked on the test system when you set x and y to 1. In production it did not work even with x and y set to 1. We had to use double.cmp to do the test.