The LIMIT = 1 syntax improves the speed when there are potentially a large number of results from the WHERE clause. Suppose that you are searching for invoices containing sales of a particular product during the past month. You may have several thousand invoices, with say 1,000 invoices containing the particular product. The limit clause exits the count procedure when it finds the first occurrence of the product. Rather than counting the remaining 999 occurrences, the procedure exits immediately.

It unfortunately does not increase the speed of "No occurrences".

Albert

On 12/05/2012 12:24 AM, Tony IJntema wrote:

I don’t see how the limit = 1 condition would improve the speed.

Normally the where clause is evaluated from left to right (It depends on the AND setting).

If the last statement in the where clause is limit = 1, this one is performed after all other conditions have been met.

So theoretically speaking it would slow down the performance.

As a human being I would use the limit = 1 condition, but I think that’s the difference between me and my computer

Or do I miss something?

Tony

*From:*[email protected] [mailto:[email protected]] *On Behalf Of *Javier Valencia
*Sent:* zaterdag 12 mei 2012 4:37
*To:* RBASE-L Mailing List
*Subject:* [RBASE-L] - RE: error message

Jan,

You are correct. I normally use the SELECT (COUNT(…); I have been gradually changing COMPUTE to SELECT and using, as Albert indicated, the LIMIT = 1 syntax.

How ironic that the first snippet of code I grab is one with the old syntax, even when I completely updated the form where that code resides; I don’t know how I missed that. I need to do a search of all forms for COMPUTE and update the code.

Javier,

Javier Valencia, PE

O: 913-829-0888

H: 913-397-9605

C: 913-915-3137

*From:*[email protected] <mailto:[email protected]> [mailto:[email protected]] *On Behalf Of *jan johansen
*Sent:* Friday, May 11, 2012 3:34 PM
*To:* RBASE-L Mailing List
*Subject:* [RBASE-L] - RE: error message

Javier,

Out of curiosity, I'm wondering if your code

-- Check if records are available

COMPUTE vcount AS COUNT equip_code FROM fuel_usage_file +

WHERE equip_code = .vequip_code AND +

fuel_date BETWEEN .vfrom_date AND .vto_date

would operate faster as

SELECT (COUNT(equip_code)) INTO vcount INDIC ivcount +

FROM fuel_usage_file +

WHERE equip_code = .vequip_code AND +

fuel_date BETWEEN .vfrom_date AND .vto_date

Jan

    -----Original Message-----
    From: "Javier Valencia" <[email protected]
    <mailto:[email protected]>>
    To: [email protected] <mailto:[email protected]> (RBASE-L Mailing
    List)
    Date: Fri, 11 May 2012 14:58:21 -0500
    Subject: [RBASE-L] - RE: error message

    Dan,

    Here is a snippet of code I use in similar circumstances. In this
    case to display records for a time period:

    ==========

    LABEL Resel

    SET VAR vfrom_date DATE = (RDATE(1,1,(IYR(.#DATE))))

    SET VAR vto_date DATE = (.#DATE)

    --Form date_from_to allows the user to enter a date range. It has
    several preset date ranges

    EDIT USING date_from_to

    -- Check if user slected range or cancelled

    IF ( vprint <> 'Y' ) THEN

      SET VAR vresel = 'N'

      GOTO Done

    ENDIF

    -- Check if records are available

    COMPUTE vcount AS COUNT equip_code FROM fuel_usage_file +

    WHERE equip_code = .vequip_code AND +

    fuel_date BETWEEN .vfrom_date AND .vto_date

    IF ( vcount > 0 ) THEN

      BROWSE USING fuel_usage_list WHERE equip_code = .vequip_code AND +

      fuel_date BETWEEN .vfrom_date AND .vto_date +

      ORDER BY fuel_date DESC, fuel_time DESC

    ELSE

      PAUSE 2 USING 'No Fuel Usage Records found for this Time
    Period...' +

      CAPTION 'System Message...' ICON ATTENTION

      GOTO Resel

    ENDIF

    LABEL DONE

    CLEAR VAR vcount, vfrom_date, vto_date

    RETURN

    ==========

    This approach prevents message displays and informs the user if
    records are not available.

    I have another approach that as soon as the user selects the time
    period, the number of available records is displayed in the same
    form; if 0 the user can either cancel or enter a new time period.

    Javier,

    Javier Valencia, PE

    O: 913-829-0888

    H: 913-397-9605

    C: 913-915-3137

    *From:*[email protected] <mailto:[email protected]>
    [mailto:[email protected]] <mailto:[mailto:[email protected]]> *On
    Behalf Of *Dan Goldberg
    *Sent:* Friday, May 11, 2012 1:32 PM
    *To:* RBASE-L Mailing List
    *Subject:* [RBASE-L] - RE: error message

    I will have to change my thought process. I do not like to give
    the user the standard error messages....

    Dan

    *From:* Tony IJntema <mailto:[email protected]>

    *Sent:*Friday, May 11, 2012 6:52 AM

    *To:*RBASE-L Mailing List <mailto:[email protected]>

    *Subject:*[RBASE-L] - RE: error message

    As it said, it is a warning not an error.

    I assume

    Another way to avoid this message is to perform a count on
    beforehand, like ‘select count(*) into V_counter indicator
    VIND_counter from <tableview> where <clause>’

    If V_Counter > 0 then

    …

    This last option is often used by me, it creates more control in
    the application

    Tony

    *From:*[email protected] <mailto:[email protected]>
    [mailto:[email protected]] <mailto:[mailto:[email protected]]> *On
    Behalf Of *Dan Goldberg
    *Sent:* vrijdag 11 mei 2012 15:23
    *To:* RBASE-L Mailing List
    *Subject:* [RBASE-L] - error message

    I have some code that includes

    set messages off

    set error messages off

    But I still keep getting the warning:

    <WARNING> No rows exist or satisfy specified clause (2059)

    The only way to turn it off is by using

    set error message 2059 OFF

    Shouldn’t the “set error messages off” turn off all error messages?

    Dan Goldberg

No virus found in this message.
Checked by AVG - www.avg.com <http://www.avg.com>
Version: 2012.0.2171 / Virus Database: 2425/4992 - Release Date: 05/11/12


--- RBASE-L
=======================3D=======================3
D=
TO POST A MESSAGE TO ALL MEMBERS:
Send a plain text email to [email protected]

(Don't use any of these words as your Subject:
INTRO, SUBSCRIBE, UNSUBSCRIBE, SEARCH,
REMOVE, SUSPEND, RESUME, DIGEST, RESEND, HELP)
=======================3D=======================3
D=
TO SEE MESSAGE POSTING GUIDELINES:
Send a plain text email to [email protected]
In the message SUBJECT, put just one word: INTRO
=======================3D=======================3
D=
TO UNSUBSCRIBE:
Send a plain text email to [email protected]
In the message SUBJECT, put just one word: UNSUBSCRIBE
=======================3D=======================3
D=
TO SEARCH ARCHIVES:
Send a plain text email to [email protected]
In the message SUBJECT, put just one word: SEARCH-n
(where n is the number of days). In the message body,
place any
text to search for.
=======================3D=======================3
D=


Reply via email to