home *** CD-ROM | disk | FTP | other *** search
- create apt proc dscin_1() as
- begin
- variable vstoreid char(5)
- variable descrip char(40)
- variable vlowqty int
- variable status int
-
- useform sdsc_3
- channel sqlrowch
-
- /*
- ** Note: sqlrows must not use $channel, the default channel.
- */
- define discquery sqlrow on sqlrowch
- sqlbegin
- select discounttype, stor_id, lowqty, highqty,
- percent = discount
- from discounts
- where stor_id = {sqlexpr(storeid)}
- or {quantity} >= lowqty
- or {quantity} <= highqty
- or (stor_id = NULL and lowqty = NULL
- and highqty = NULL)
- sqlend
-
- /*
- ** Beginning of executable statements.
- */
-
- /* The second channel, needed for sqlrows, is not opened until it
- ** is actually needed. This cuts down on the application startup
- ** time. The channel is closed when the application shuts down,
- ** since we don't want to keep opening and closing expensive channels.
- */
- if sqlrowch:open = FALSE
- begin
- connect sqlrowch
- submit on sqlrowch
- sqlbegin
- use pubs
- sqlend
- end
-
- /*
- ** Clear the discount group, then load it from the database. Note
- ** that the "description" field is composed from descriptive words
- ** and data from the Server, rather than a straight transfer.
- */
- reset grpdiscount
-
- opensql discquery
- foreach discquery
- begin
- /* The transfer transfers just the 'discount', a percentage. */
- transfer discquery
-
- descrip = discquery(discounttype) + " "
-
- /* At this time, "sqlrow(col) is NULL" is not a legal statement.
- ** So we transfer column data to APT-SQL variables vstoreid and
- ** vlowqty, and then test for NULL.
- */
- vstoreid = discquery(stor_id)
- if vstoreid is not NULL
- begin
- descrip = descrip + "Store Id:" + discquery(stor_id)
- end
-
- vlowqty = discquery(lowqty)
- if vlowqty is not NULL
- begin
- descrip = descrip + discquery(lowqty):text + " -> " +
- discquery(highqty):text
- end
-
- grpdiscount[discquery:index].description = descrip
- end
- closesql discquery
-
- adddisc = 0
- save field adddisc
- totpercent = 0
-
- call clcst_1(quantity, totpercent, price, totalcost, status)
-
- return
- end
-