1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Progress Browse-query help

Discussion in 'Development' started by tke1046, Apr 18, 2006.

  1. tke1046

    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?
     
  2.  
  3. tke1046

    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?
     
  4. joey.jeremiah

    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 (progress):
    1.  
    2. /* define the query */
    3.  
    4. define query qryOrder
    5.  
    6.     for order, customer, salesrep /* buffers in the query */
    7.  
    8.         scrolling. /* lets the query move backwards and forwards
    9.                     * theres no need to specify it, it is implicit
    10.                     * for queries used in browsers */
    11.  
    12.  
    13.  
    14. /* define the browse */
    15.  
    16. define browse brwOrder
    17.  
    18.     query qryOrder /* in many ways it binds the query to that browse */
    19.  
    20.     display
    21.         order.ordernum
    22.         order.orderdate
    23.         order.terms
    24.  
    25.         customer.custnum
    26.         customer.name
    27.  
    28.         salesrep.salesrep
    29.         salesrep.repname
    30.  
    31.     with 10 down width 40.
    32.  
    33.  
    34.  
    35. /* put the browse in a frame (explicitly) */
    36.  
    37. form
    38.  
    39.     brwOrder
    40.  
    41. with frame frmOrder.
    42.  
    43.  
    44.  
    45. /* now that every thing is defined, lets open the query.
    46.  * the entire query is not populated (satisfied)
    47.  * instead the browse only reads the records needed to fill the screen */
    48.  
    49. open query qryOrder
    50.  
    51.     /* now this is very important.
    52.      * don't use joins without a matching index ( or indexes that are atleast close enough ) !
    53.      * in that case you will need to create a temp-table first */
    54.  
    55.     /* make sure your queries are efficient !
    56.      * otherwise you'll endup with some very angry customers */
    57.  
    58.     for each order no-lock,
    59.  
    60.         first customer of order no-lock,
    61.  
    62.         first salesrep of order no-lock
    63.  
    64.         indexed-reposition. /* useful when jumping over many records e.g. reposition to rowid
    65.                              * try using the "end" key function with or without it
    66.                              * there are trade offs, you might want to read about it first */
    67.  
    68.  
    69.  
    70. enable all with frame frmOrder.
    71.  
    72. wait-for window-close of current-window.
    73.  
    i highly recommend reading the chapters on queries and browsers in the programming handbook, besides the online f1 help. hth
     

Share This Page