NUM-RESULTS property being returned as zero.

Posted by LegacyUser on 15-Mar-2006 03:06

Hello,

Can anyone tell me why the NUM-RESULTS property from the following code is being returned as zero?

DEF VAR hQry AS HANDLE NO-UNDO.

DEF VAR hBuf AS HANDLE NO-UNDO.

CREATE QUERY hQry.

CREATE BUFFER hBuf FOR TABLE "customer".

hQry:ADD-BUFFER(hBuf).

hQry:QUERY-PREPARE("FOR EACH customer NO-LOCK").

hQry:QUERY-OPEN.

MESSAGE hQry:NUM-RESULTS VIEW-AS ALERT-BOX.

hQry:QUERY-CLOSE.

I can use the QUERY-NEXT method to count the number of records in the table, but I thought using the NUM-RESULTS property would be more efficient?!

Thanks in advance.

All Replies

Posted by svi on 15-Mar-2006 09:07

You are not using the PRESELECT option so the entire results list is not built immediately. Without PRESELECT, NUM-RESULTS might not return the number of rows in the browse.

HIH

Salvador

Posted by LegacyUser on 16-Mar-2006 01:44

Thanks Svi - much apprecaited.

The following change to the code worked a treat...

DEF VAR hQry AS HANDLE NO-UNDO.

DEF VAR hBuf AS HANDLE NO-UNDO.

CREATE QUERY hQry.

CREATE BUFFER hBuf FOR TABLE "customer".

hQry:ADD-BUFFER(hBuf).

hQry:QUERY-PREPARE("PRESELECT EACH customer").

hQry:QUERY-OPEN.

MESSAGE hQry:NUM-RESULTS VIEW-AS ALERT-BOX.

hQry:QUERY-CLOSE.

This thread is closed