Progress Browse-query help

tke1046

New Member
Hello out there! I'm a bit of a newb in the realm of Progress programming and I have a question regarding the Browse-query functionality. From all the literature I have seen, it appears to me as if the query associated with a browse should only pull from 1 table, meaning that joins in a query are not really allowed. The program I am working with requires that I join multiple table to get all the fields I need to display in my browse. Here is my browse-query code:

open query q-order for each ld_mstr,
each so_mstr where so_mstr.so_nbr = ld_mstr.ldm_ord,
each cm_mstr where cm_mstr.cm_addr = so_mstr.so_cust,
each ccr_default where ccd_param = "CCR_CHEP" and
ccd_value = yes and ccd_cust = cm_mstr.cm_addr.

define browse brw-Order query q-order
display
ccr_default.ccd_param
ccr_default.ccd_value
so_mstr.so_cust
ld_mstr.ldm_nbr
ld_mstr.ldm_chep_outdt
with width 75 5 down title "Orders".

Is this correct or is there some other way to do joins in the query definition?
 

tke1046

New Member
I think I may have figured it out....Is the correct route to create a temp table by doing my search and then to have my browse query use the temp-table for the browse?
 

joey.jeremiah

ProgressTalk Moderator
Staff member
theres no need to build a temp-table first, not in this case.

queries associated with browsers or not can have multiple ( inner/outer )joins.



Code:
/* define the query */

define query qryOrder

    for order, customer, salesrep /* buffers in the query */

        scrolling. /* lets the query move backwards and forwards
                    * theres no need to specify it, it is implicit
                    * for queries used in browsers */



/* define the browse */

define browse brwOrder

    query qryOrder /* in many ways it binds the query to that browse */

    display
        order.ordernum
        order.orderdate
        order.terms

        customer.custnum
        customer.name

        salesrep.salesrep
        salesrep.repname

    with 10 down width 40.



/* put the browse in a frame (explicitly) */

form

    brwOrder

with frame frmOrder.



/* now that every thing is defined, lets open the query.
 * the entire query is not populated (satisfied)
 * instead the browse only reads the records needed to fill the screen */

open query qryOrder

    /* now this is very important.
     * don't use joins without a matching index ( or indexes that are atleast close enough ) !
     * in that case you will need to create a temp-table first */

    /* make sure your queries are efficient !
     * otherwise you'll endup with some very angry customers */

    for each order no-lock,

        first customer of order no-lock,

        first salesrep of order no-lock

        indexed-reposition. /* useful when jumping over many records e.g. reposition to rowid
                             * try using the "end" key function with or without it
                             * there are trade offs, you might want to read about it first */



enable all with frame frmOrder.

wait-for window-close of current-window.

i highly recommend reading the chapters on queries and browsers in the programming handbook, besides the online f1 help. hth
 
Top