Logic problem with exercise 11 in 4gl by example
"James B. Byrne via Aubit4gl-discuss" <[email protected]> Thu, 11 Mar 2021 09:57:23 -0500
| Newsgroups | gmane.comp.lang.4gl.aubit.general |
|---|---|
| Message-ID | <[email protected]> |
The text I am working from contains this code segment:
LET st_stock =
"SELECT stock_num, description, stock.manu_code, manufact.manu_name, ",
"unit, unit_price FROM stock, manufact"
IF stock_item IS NOT NULL THEN
LET st_stock = st_stock CLIPPED, " WHERE stock_num = ", stock_item,
" AND stock.manu_code = manufact.manu_code",
" ORDER BY 1, 3"
ELSE
LET st_stock = st_stock CLIPPED,
" WHERE stock.manu_code = manufact.manu_code",
" ORDER BY 1, 3"
END IF
PREPARE slct_run FROM st_stock
DECLARE c_stockpop CURSOR FOR slct_run
The purpose of this code is to populate a popup list containing all the stock
items matching the selection criteria.
Here is my problem. I must assume that this code has been tested by
innumerable people so whatever is happening is due to some misunderstanding on
my part. However:
The screen field stock_item occurs before the screen field manu_code. The
popup may be called from either field. If the stock_item field is NULL, as it
will be if one chooses to display the popup, then the manu_code field will also
necessarily be NULL as it has not yet been activated for input.
But this code seems to say that if the stock_item is NULL then it expects that
the manu_code will not be NULL. I have DISPLAYed the resulting query in this
case and it says this:
SELECT stock_num, description, stock.manu_code, manufact.manu_name, unit,
unit_price FROM stock, manufact WHERE stock.manu_code = manufact.manu_code
ORDER BY 1, 3
But this will always return the empty set since there cannot be any stock_items
without an associated manu_code.
What am I missing?
--
*** e-Mail is NOT a SECURE channel ***
Do NOT transmit sensitive data via e-Mail
Unencrypted messages have no legal claim to privacy
Do NOT open attachments nor follow links sent by e-Mail
James B. Byrne mailto:[email protected]
Harte & Lyne Limited http://www.harte-lyne.ca
9 Brockley Drive vox: +1 905 561 1241
Hamilton, Ontario fax: +1 905 561 0757
Canada L8E 3C3