如何使用浏览器按升序或降序搜索和显示名称

时间:2016-10-06 06:37:59

标签: progress-4gl

当我使用姓名的起始字母在名称填写中搜索时,它应显示以该字母开头的所有名称。

提示:它应该使用open query`

DO:
    IF (input customer.cust-num <> 0)  and (input customer.name = "")  then do:
        find first customer where ( customer.cust-num = input cust-num) no-error.
        OPEN QUERY custqry FOR EACH customer.
        display customer.cust-num customer.name customer.balance customer.discount customer.credit-limit customer.phone customer.contact with browse br1 . /*to display in browser*/
        assign
            ocustnum      = customer.cust-num
            oName         = customer.Name
            obalance      = customer.balance
            odiscount     = customer.discount
            ocredit-limit = customer.credit-limit
            ophone        = customer.phone
            ocontact      = customer.contact .
        display ocustnum oName obalance odiscount ocredit-limit ophone ocontact with frame default-frame  . /*to display in fillin*/
    end.
    ELSE IF (input customer.cust-num = 0)  and (input customer.name <> "") then do:
        find first customer where customer.name begins input name no-error .
        OPEN QUERY q FOR EACH customer BY name.     
        display customer.cust-num customer.name customer.balance customer.discount customer.credit-limit customer.phone customer.contact with browse br1. /*to display in browser*/
        assign
            ocustnum      = customer.cust-num
            oName         = customer.Name
            obalance      = customer.balance
            odiscount     = customer.discount
            ocredit-limit = customer.credit-limit
            ophone        = customer.phone
            ocontact      = customer.contact .
        display ocustnum oName obalance odiscount ocredit-limit ophone ocontact with frame default-frame  . /*to display in fillin*/   
    end.      
    ELSE IF (input customer.cust-num <> 0)  and (input customer.name <> "") then do:  
        find first customer where ( customer.cust-num = input cust-num) and (customer.name begins input name) no-lock  no-error .
        OPEN QUERY cust-query FOR EACH customer BY name.
        display customer.cust-num customer.name customer.balance customer.discount customer.credit-limit customer.phone customer.contact with browse br1. /*to display in browser*/
        assign
            ocustnum      = customer.cust-num
            oName         = customer.Name
            obalance      = customer.balance
            odiscount     = customer.discount
            ocredit-limit = customer.credit-limit
            ophone        = customer.phone
            ocontact      = customer.contact .
        display ocustnum oName obalance odiscount ocredit-limit ophone ocontact with frame default-frame  . /*to display in fillin*/   
   end.  
END.

` 我为搜索按钮编写的上述代码。enter image description here

1 个答案:

答案 0 :(得分:0)

使用BEGINS匹配字符串的开头并使用BY控制排序顺序:

OPEN QUERY q FOR EACH customer 
                WHERE customer.name BEGINS (INPUT customer.name) BY name.