Query object question

jmac13

Member
Hi all,
I'm using open edge 10.2b

I've created a query on the fly then applied it to browse but when i do num-results("{&browse-name}") it doesn’t work as the Query on the browse has no name. In the help it says the name attribute is a readable/writeable but this doesn’t seem the case for the query object (which is helpful). Is there anyway round this? I've tried using the num-results for my query object but it doesn’t represent whats in the browse.


Example code:

Code:
define variable chrQuery as character no-undo.
define variable chrQueryWhere as character no-undo.
define variable hanQuery      as handle    no-undo. 
define variable hanTempTable as handle     no-undo.
hanTempTable = buffer ttRecs:handle.

CREATE QUERY hanQuery.
hanQuery:SET-BUFFERS(hanTempTable).

do with frame {&frame-name}:
    
    chrQuery = "FOR EACH " + "ttRecs" + " " + chrQueryWhere + " NO-LOCK".
    hanQuery:query-prepare(chrQuery).
    hanQuery:query-open().
    brDetail:query = hanQuery.
       /*Browse query name now nothing!*/
    intNoRecords    =   num-results("{&browse-name}").       /*IntnoRecords = 0 now*/
end.
 

Cringer

ProgressTalk.com Moderator
Staff member
Am I missing something, or can you not do
hanQuery:num-results?
 

medu

Member
num-results is really about the query and since you have the handle then just go ahead and use the attribute: hanQuery:num-results.

what you are probably seing is that this is 0 but if will change as soons as more records are loaded and the result-set it's build... if you want to have it built from the start then you might change the 'for each' to 'preselect each' but this might not be what you want if there are a considerable number of records :)
 

UncleNel

New Member
Two things need to be done for num-results:
1) use handle:num-results (already mentioned).
2) Change your "for each: to "preselect each". Num-results after an open with "for each" will return 0, "preselect" will return the query count.
 

jmac13

Member
Thanks for the reply guys... Yeah i tried using num-results with preselect but then doesnt seem to display in my browse then.... and doesnt seem to count the records right
 

jmac13

Member
I think thats because my display code is doing

{&open-query-{&view-browse-name}}




hmmm might have to just get rid of the count thing for this one until this display code is sorted.. i
 

jmac13

Member
just realised I was creating a query object and didnt need one. I just passed my chrQuery
to the browse and it worked fine.


Code:
   chrQuery = "preselect each " + "ttRecs" + " " + chrQueryWhere + " NO-LOCK".
    
    brDetail:query-prepare(chrQuery).
    brDetail:query-open().
 
    intNoRecords    =   num-results("{&browse-name}").


thanks all for your help
 
Top