Whilst rereading my original post on this subject, an alternative solution suddenly popped into my head. As I wrote then, the way which I have found to solve this problem is to calculate how many records there are in the suptypes table before it is linked as a procedure, then do the same after the table has been linked. If the results are the same then the user wanted everything, but if they differ, then suppliers without a suptype should not be included. I presented the following snippet of code which checks how many supplier types there are in total and how many have been passed as in the parameter.
:LINKED = :UNLINKED = :SUP = :TYP = 0; SELECT COUNT (*) INTO :UNLINKED FROM SUPTYPES; LINK SUPTYPES TO :$.TYP; ERRMSG 1 WHERE :RETVAL <= 0; SELECT COUNT (*) INTO :LINKED FROM SUPTYPES;
It occurs to me now that there is a simpler solution to remove the zero values when they are not required: simply delete the zero record from the linked suptypes table:
GOTO 1 WHERE :LINKED = :UNLINKED; DELETE FROM SUPTYPES WHERE SUPTYPE = 0; LABEL 1;
This way, there's no need to check whether zeroes are required and whether the current record is a 'zero'. The result should be that the procedure runs slightly faster.
Edit from a few weeks later: this 'optimisation' does not work!
Edit from a few weeks later: this 'optimisation' does not work!
No comments:
Post a Comment